I have currently a dataframe which looks like this and I have done a df["Keywords"] = df["Keywords"].str.split(" ")
ID | Keywords
1 | [agile]
2 | [python, python, python]
3 | [agile, agile]
What I would like to achieve is something like this in which I tranpose the values into column headers and do a count. I tried to expand=true but that didnt work. Is there anyway I can achieve this?
ID | agile | python
1 | 1 | 0
2 | 0 | 1
3 | 1 | 0
>Solution :
Don’t split.. you can directly encode the values using get_dummies
df[['ID']].join(df['Keywords'].str.get_dummies(sep=' '))