Reset column index of pandas dataframe

后端 未结 3 1497
隐瞒了意图╮
隐瞒了意图╮ 2021-01-22 07:36

Is it possible to reset columns so they becomes first row of DataFrame. For example,

import pandas as pd

df = pd.DataFrame({\'a\': [1, 2, 3], \'b\'         


        
3条回答
  •  滥情空心
    2021-01-22 08:24

    Can also chain reset.index

    df.T.reset_index().T.reset_index(drop=True)
    
        0   1
    0   a   b
    1   1   4
    2   2   5
    3   3   6
    

提交回复
热议问题