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

Popular posts from this blog

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

android - ConstraintLayout: Realign baseline constraint in case if dependent view visibility was set to GONE -

c# - Populating Gridview inside Listview ItemTemplate On Web User Control from Code Behind -