【发布时间】:2019-12-14 15:07:22
【问题描述】:
我的数据是:
a=pd.DataFrame({'sentences':['i am here','bye bye','go back home quickly']})
当我使用 split 时,我可以将字符串转换为单个单词:
a.loc[:,'sentences1']=a.loc[:,'sentences'].astype(str).str.split(' ')
结果是:
sentences sentences1
0 i am here [i, am, here]
1 bye bye [bye, bye]
2 go back home quickly [go, back, home, quickly]
现在,我想将列表整合到“sentences1”列中,然后删除重复项。所以它看起来像:
[i, am, here, bye, go, back, home, quickly]
我该怎么做?
【问题讨论】: