import ast
L = [ast.literal_eval(x) for x in df["column"]]
print (L)
[['tablet', 'mobile', 'man'], ['people', 'house'],
['people', 'computer'], ['computer', 'laptop']]
import pandas as pd
result_list = []
df = pd.read_csv("file_name")
series_1 = df.loc[::, "column_name"]
for s in series_1:
result_list.append(s)
print(result_list)
4条答案
按热度按时间vfh0ocws1#
使用
ast.literal_eval
转换列表解析中的字符串列表:62o28rlo2#
ccrfmcuu3#
如果你
df
就像您可以通过使用
tolist()
调用列来获取列表输出量:
kxkpmulp4#