例如:
df_test=pd.DataFrame([('tokyo',123),('london',11),('sydney',22),('taiwan',33),('hongkong',23),('la', 32)], columns=['city','count'])
city count
0 tokyo 123
1 london 11
2 sydney 22
3 taiwan 33
4 hongkong 23
5 la 32
我希望它看起来像这样,因为行比列太多,所以很容易阅读
city count city count
0 tokyo 123 taiwan 33
1 london 11 hongkong 23
2 sydney 22 la 32
您可以按索引值使用模和整数除法,并按^{} 重新整形,最后一次排序为第二级,为避免重复列名称,请将
MultiIndex in columns
展平:如果可能,不使用默认值
RangeIndex
可以使用:编辑:按行长计数
N
的常规数据始终为4列的解决方案:相关问题 更多 >
编程相关推荐