how change column strin of list data type to list

Solutions on MaxInterview for how change column strin of list data type to list by the best coders in the world

showing results for - "how change column strin of list data type to list"
Marta
25 Jun 2018
1from ast import literal_eval
2import pandas as pd
3
4# convert the column during import
5df = pd.read_csv('test.csv', converters={'col1': literal_eval})
6
7# display(df)
8                                col1
90                       [1.23, 2.34]
101  [KB4523205, KB4519569, KB4503308]
11
12# check type
13print(type(df.iloc[0, 0]))
14list
15
16print(type(df.iloc[1, 0]))
17list
18
similar questions