我有一张桌子:
Name1 Name2 Name3
0 ABC FGD NNY
1 111S PC 1T Trees are always yellow NaN NaN
2 P FGD NNY
3 JJJ FGD NNY
4 111S PC 1T Trees are always yellow NaN NaN
5 ABC FGD NNY
6 UIK GJ DE
我想得到这个:
Name1 Name2 Name3 Name4
0 ABC FGD NNY NaN
1 111S PC 1T Trees are always yellow
2 P FGD NNY NaN
3 JJJ FGD NNY NaN
4 111S PC 1T Trees are always yellow
5 ABC FGD NNY NaN
6 UIK GJ DE NaN
我只需要拆分一些行,其他行不应更改。 我能够确定需要拆分数据的行:
if df[colname1].isnull:
df_index=df[df[colname1].isnull()].index
print(df_index)
现在需要分离值串串的。我有这样的感觉:
if df[colname1].isnull:
df_index=df[df[colname1].isnull()].index
print(df_index)
for i in df_index:
print(i)
df1=df[colname][i].split(' ')
df1是一个字符串,其中包含我需要的信息,但我不知道如何将这些信息放到数据帧df的需要的索引中。 你能帮我做这个吗
IIUC您有一个双空格来分隔列,在句子中有一个空格。您可以使用它来执行拆分
使用
str.split
和n
相关问题 更多 >
编程相关推荐