我有一个数据帧,在下面-
0
____________________________________
0 Country| India
60 Delhi
62 Mumbai
68 Chennai
75 Country| Italy
78 Rome
80 Venice
85 Milan
88 Country| Australia
100 Sydney
103 Melbourne
107 Perth
我想把数据分成两列,这样一列是国家,另一列是城市。我不知道从哪里开始。我想要下面这样-
0 1
____________________________________
0 Country| India Delhi
1 Country| India Mumbai
2 Country| India Chennai
3 Country| Italy Rome
4 Country| Italy Venice
5 Country| Italy Milan
6 Country| Australia Sydney
7 Country| Australia Melbourne
8 Country| Australia Perth
你知道怎么做吗
使用^{} with ^{} 和^{} 将不匹配的值替换为缺少的值,使用} 删除两个值相同的行,用于^{} 中的不相等:
ffill
向前填充缺少的值,然后通过^{查找存在
|
的行并拉入另一列,然后填充新创建的列:相关问题 更多 >
编程相关推荐