Quickest Way To Make A Get_dummies Type Dataframe From A Column With A Multiple Of Strings
I have a column, 'col2', that has a list of strings. The current code I have is too slow, there's about 2000 unique strings (the letters in the example below), and 4000 rows. Endin
Solution 1:
You can use:
>>> df['col2'].str.get_dummies(sep=',')
ABCG011001101120100
To join the Dataframes:
>>> pd.concat([df, df['col2'].str.get_dummies(sep=',')], axis=1)
col1col2ABCG06A,B1100115C,G,A1011225B0100
Post a Comment for "Quickest Way To Make A Get_dummies Type Dataframe From A Column With A Multiple Of Strings"