I want to remove the list type in my pandas data frame. So far every string is in a list. I want to keep the string and remove the list. Thank you
CodePudding user response:
You can try
df.filter('decision') = df.filter('decision').applymap(lambda lst: eval(lst)[0])
# or
cols = ['decision1 category', 'decision2 category', 'decision3 category']
df[cols] = df[cols].applymap(lambda lst: eval(lst)[0])