How to convert index of a pandas dataframe into a column?

前端 未结 7 568
后悔当初
后悔当初 2020-11-22 08:54

This seems rather obvious, but I can\'t seem to figure out how to convert an index of data frame to a column?

For example:

df=
        gi       ptt_l         


        
相关标签:
7条回答
  • 2020-11-22 09:48

    For MultiIndex you can extract its subindex using

    df['si_name'] = R.index.get_level_values('si_name') 
    

    where si_name is the name of the subindex.

    0 讨论(0)
提交回复
热议问题