Home > front end >  Get values out of sub lists in data frame
Get values out of sub lists in data frame

Time:05-14

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 youenter image description here

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])
  • Related