I have a dataframe like this:
text category
sfsd sgvv abc,xyz
zydf sefs sdfsd yyy
dfsd dsrgd dggr xyz
eter vxg
Linking to this question, try the following code for your dataframe:
We can first split the column, expand it, stack it and then join it back to the original df like below:
df.drop('category', axis=1).join(
df['category'].str.split(',', expand=True).stack().reset_index(level=1,drop=True).rename('category'))