【发布时间】:2019-05-12 09:49:47
【问题描述】:
我的 pandas 数据框由文本列表组成,我想将文本拆分为 ,
df['c1']=['this is text one','this is text two','this is text three']
我试过了
new = df["c1"].str.split(",", n = 1, expand = True)
但我是 Nan 在新变量上
预期输出
c1='this is text one'
c1='this is text two'
c1='this is text three'
只要拆分列表中的文本,其他输出就可以了。感谢您的帮助 完整代码
import pandas as pd
data={"C1":[["this is text one","this is text two","this is text three"]]}
df=pd.DataFrame(data)
df.head()
【问题讨论】:
-
我能看到完整的代码吗?
-
我无法分享完整的代码,但流程看起来像这样 ``` import pandas as pd data={"C1":[["this is text one","this is text two ","这是文本三"]]} df=pd.DataFrame(data) print(df.head()) ```
-
我想知道df数组的结构
标签: python string pandas list python-3.6