Answers for "how change column strin of list data type to list"

0

how change column strin of list data type to list

from ast import literal_eval
import pandas as pd

# convert the column during import
df = pd.read_csv('test.csv', converters={'col1': literal_eval})

# display(df)
                                col1
0                       [1.23, 2.34]
1  [KB4523205, KB4519569, KB4503308]

# check type
print(type(df.iloc[0, 0]))
list

print(type(df.iloc[1, 0]))
list
Posted by: Guest on August-31-2021

Code answers related to "how change column strin of list data type to list"

Python Answers by Framework

Browse Popular Code Answers by Language