我有一只熊猫DataFrame,有三栏。
df = pd.read_csv('doc.csv')
document year Keywords
1 2018 Appliance Interaction; Intrusive Load Monitoring; Appliance Identification
2 2018 wireless networks; Learning algorithms; operator recommendations
3 2019 Natural Language; Crowdsourcing; Natural Language; Sensemaking 数据:
{'document': [1, 2, 3],
'year': [2018, 2018, 2019],
'Keywords': ['Appliance Interaction; Intrusive Load Monitoring; Appliance Identification',
'wireless networks; Learning algorithms; operator recommendations',
'Natural Language; Crowdsourcing; Natural Language; Sensemaking']}我想要做的是将列(关键字)转换为如下所示的列表
X = [Appliance Interaction, Intrusive Load Monitoring, Appliance Identification, wireless networks, Learning algorithms, operator recommendations, Natural Language, Crowdsourcing, Natural Language, Sensemaking]并将此列表保存到单独的CSV文件中。
发布于 2022-02-15 21:15:29
您可以在"; " + explode上拆分并转换为list:
X = df['Keywords'].str.split('; ').explode().tolist()输出:
['Appliance Interaction',
'Intrusive Load Monitoring',
'Appliance Identification',
'wireless networks',
'Learning algorithms',
'operator recommendations',
'Natural Language',
'Crowdsourcing',
'Natural Language',
'Sensemaking']https://stackoverflow.com/questions/71133405
复制相似问题