0

I have a COLUMN in a DataFrame with str values. I need to convert every str into list for that column because the model the required that column to be of type list. How can I do it?

for example, for each row I need to change 'some string' into ['some string']

Sauron
  • 13
  • 5
  • 3
    `df['COLUMN'] = df['COLUMN'].apply(lambda v: [v])` – Code Different Sep 09 '19 at 20:58
  • Take a look at these: https://stackoverflow.com/questions/34962104/pandas-how-can-i-use-the-apply-function-for-a-single-column and https://thispointer.com/pandas-apply-apply-a-function-to-each-row-column-in-dataframe/ for more general explanations – Ehsan Fathi Sep 09 '19 at 21:12
  • https://pandas.pydata.org/pandas-docs/stable/ – wwii Sep 09 '19 at 21:30

0 Answers0