这个问题在这里已经有了答案:
Get list from pandas dataframe column or row?
(7 个回答)
2年前关闭。
从数据框列中提取字符串列表,如我的代码所示:
d = {'text': ["Hello", "How are you","From","Liban"]}
df = pd.DataFrame(data=d)
df
我的 list 会有
List_text = ["Hello","How are you","From","Liban"].
谢谢
最佳答案
使用 Series.tolist
:
list_text = df.text.tolist()
print(list_text)
['Hello', 'How are you', 'From', 'Liban']
关于python - 将数据框列转换为字符串列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55839104/