扁平化熊猫中的多层列

时间:2019-08-26 14:18:23

标签: python python-3.x pandas dataframe

我有一个类似的数据框

In [1]: df
Out[1]:
   a  b  c
   d  e  f
   g  h  i
0  1  2  3
1  4  5  6
2  7  8  9

其中前三行是列

In [2]: df.columns.values
Out[2]: array([('a', 'd', 'g'), ('b', 'e', 'h'), ('c', 'f', 'i')], dtype=object)

我想将此数据帧转换为

   a  b  c
0  d  e  f
1  g  h  i
2  1  2  3
3  4  5  6
4  7  8  9

1 个答案:

答案 0 :(得分:3)

使用if('year' in this.obj) { this.obj.year //ok }

reset_index