我是Pandas的新手,刚刚开始学习。我只需要从Pandas Dataframe中删除特定的标头
我从SQL查询中获得以下数据框
Unnamed: 0_level_0 The Energy Sector
Period Hydro Power Wind Power Solar Power Total
0 January 56530 86756 7567 12312
1 February 13612 65192 2758 22112
2 March 12383 45832 1295 32112
3 April 45612 12654 1292 11212
我尝试了以下
`(df.to_string(header=True))`
这会删除所有列名并给我
0 January 56530 86756 7567 12312
1 February 13612 65192 2758 22112
2 March 12383 45832 1295 32112
3 April 45612 12654 1292 11212
我还尝试通过将.toastype和applymap方法用于将数据框转换为字符串。但这仍然行不通
但是我需要如下所示:
The Energy Sector
Period Hydro Power Wind Power Solar Power Total
0 January 56530 86756 7567 12312
1 February 13612 65192 2758 22112
2 March 12383 45832 1295 32112
3 April 45612 12654 1292 11212