python - Pandas dataframe - have column with list of strings -
i have dataframe on format:
id val 0 294 aa 1 254 bb 2 844 cc
i need 'val' column list string inside, since need join dataframe dataframe format:
id val 0 294 [aa] 1 254 [bb] 2 844 [cc]
anyone know how can accomplish this? has list, seeing other dataframe format of our db, want insert joined dataframe into.
i advise against storing non-scalar types if insist can use apply
, construct list each row:
in [53]: df['val'] = df['val'].apply(lambda x: [x]) df out[53]: id val 0 294 [aa] 1 254 [bb] 2 844 [cc]
Comments
Post a Comment