我有一个看起来像这样的数据框:
df2 = pd.DataFrame(['Apple, eggs, pineapple pizza', 'orange, soda, pepsi, cola', 'pear, watermelon, pizza, lasagna', 'apple, eggs, human sandwich, human chili'], columns=['A'])
A
0 Apple, eggs, pineapple pizza
1 orange, soda, pepsi, cola
2 pear, watermelon, pizza, lasagna
3 apple, eggs, human sandwich, human chili
我要输出的是这样:
['apple, eggs, pineapple, pizza', 'orange, soda, pepsi, cola', 'pear, watermelon, pizza, lasagna', 'apple, eggs, human sandwich, human chili']
我不确定从哪里开始,有什么建议吗?
答案 0 :(得分:1)
这是您需要的吗?
df2.A.values.tolist()
Out[412]:
['Apple, eggs, pineapple pizza',
'orange, soda, pepsi, cola',
'pear, watermelon, pizza, lasagna',
'apple, eggs, human sandwich, human chili']