好吧,我检查了问题删除 pandas 中的索引名称 https://stackoverflow.com/questions/29765548/remove-index-name-in-pandas,并且它不适用于我的情况。
所以我有一个 df,我用 pandas 将其标准化melt
,然后我将其非规范化pivot_table
。现在我有以下 df,但我想删除这个索引名称variable
.
这是 df:
df
variable Site Process cap-lo cap-up depreciation ... inv-cost max-grad min-fraction var-cost wacc
0 Mid Biomass plant 0.0 5000.0 25.0 ... 875000.0 1.500000e+15 0.0 1.4 0.07
1 Mid Coal plant 0.0 0.0 40.0 ... 600000.0 1.500000e+15 0.0 0.6 0.07
2 Mid Gas plant 0.0 80000.0 30.0 ... 450000.0 1.500000e+15 0.0 1.6 0.07
3 Mid Hydro plant 0.0 1400.0 50.0 ... 1600000.0 1.500000e+15 0.0 0.0 0.07
4 Mid Lignite plant 0.0 60000.0 40.0 ... 600000.0 1.500000e+15 0.0 0.6 0.07
5 Mid Solar plant 0.0 160000.0 25.0 ... 600000.0 1.500000e+15 0.0 0.0 0.07
6 Mid Wind plant 0.0 13000.0 25.0 ... 1500000.0 1.500000e+15 0.0 0.0 0.07
7 North Biomass plant 0.0 6000.0 25.0 ... 875000.0 1.500000e+15 0.0 1.4 0.07
8 North Coal plant 0.0 100000.0 40.0 ... 600000.0 1.500000e+15 0.0 0.6 0.07
9 North Gas plant 0.0 100000.0 30.0 ... 450000.0 1.500000e+15 0.0 1.6 0.07
10 North Hydro plant 0.0 20000.0 50.0 ... 1600000.0 1.500000e+15 0.0 0.0 0.07
11 North Lignite plant 0.0 0.0 40.0 ... 600000.0 1.500000e+15 0.0 0.6 0.07
12 North Solar plant 0.0 3000.0 25.0 ... 600000.0 1.500000e+15 0.0 0.0 0.07
13 North Wind plant 0.0 60000.0 25.0 ... 1500000.0 1.500000e+15 0.0 0.0 0.07
14 South Biomass plant 0.0 0.0 25.0 ... 875000.0 1.500000e+15 0.0 1.4 0.07
15 South Coal plant 0.0 100000.0 40.0 ... 600000.0 1.500000e+15 0.0 0.6 0.07
16 South Gas plant 0.0 100000.0 30.0 ... 450000.0 1.500000e+15 0.0 1.6 0.07
17 South Hydro plant 0.0 0.0 50.0 ... 1600000.0 1.500000e+15 0.0 0.0 0.07
18 South Lignite plant 0.0 0.0 40.0 ... 600000.0 1.500000e+15 0.0 0.6 0.07
19 South Solar plant 0.0 600000.0 25.0 ... 600000.0 1.500000e+15 0.0 0.0 0.07
20 South Wind plant 0.0 200000.0 25.0 ... 1500000.0 1.500000e+15 0.0 0.0 0.07
我想删除这个variable
高于索引。我该怎么做呢?
它可能不是索引名称,而是列名称...我只想删除变量。
PS: df.index.name = 'blah'
执行以下操作:
df
variable Site Process cap-lo cap-up depreciation ... inv-cost max-grad min-fraction var-cost wacc
blah ...
0 Mid Biomass plant 0.0 5000.0 25.0 ... 875000.0 1.500000e+15 0.0 1.4 0.07
1 Mid Coal plant 0.0 0.0 40.0 ... 600000.0 1.500000e+15 0.0 0.6 0.07
2 Mid Gas plant 0.0 80000.0 30.0 ... 450000.0 1.500000e+15 0.0 1.6 0.07
3 Mid Hydro plant 0.0 1400.0 50.0 ... 1600000.0 1.500000e+15 0.0 0.0 0.07
4 Mid Lignite plant 0.0 60000.0 40.0 ... 600000.0 1.500000e+15 0.0 0.6 0.07
5 Mid Solar plant 0.0 160000.0 25.0 ... 600000.0 1.500000e+15 0.0 0.0 0.07
6 Mid Wind plant 0.0 13000.0 25.0 ... 1500000.0 1.500000e+15 0.0 0.0 0.07
7 North Biomass plant 0.0 6000.0 25.0 ... 875000.0 1.500000e+15 0.0 1.4 0.07
8 North Coal plant 0.0 100000.0 40.0 ... 600000.0 1.500000e+15 0.0 0.6 0.07
9 North Gas plant 0.0 100000.0 30.0 ... 450000.0 1.500000e+15 0.0 1.6 0.07
10 North Hydro plant 0.0 20000.0 50.0 ... 1600000.0 1.500000e+15 0.0 0.0 0.07
11 North Lignite plant 0.0 0.0 40.0 ... 600000.0 1.500000e+15 0.0 0.6 0.07
12 North Solar plant 0.0 3000.0 25.0 ... 600000.0 1.500000e+15 0.0 0.0 0.07
13 North Wind plant 0.0 60000.0 25.0 ... 1500000.0 1.500000e+15 0.0 0.0 0.07
14 South Biomass plant 0.0 0.0 25.0 ... 875000.0 1.500000e+15 0.0 1.4 0.07
15 South Coal plant 0.0 100000.0 40.0 ... 600000.0 1.500000e+15 0.0 0.6 0.07
16 South Gas plant 0.0 100000.0 30.0 ... 450000.0 1.500000e+15 0.0 1.6 0.07
17 South Hydro plant 0.0 0.0 50.0 ... 1600000.0 1.500000e+15 0.0 0.0 0.07
18 South Lignite plant 0.0 0.0 40.0 ... 600000.0 1.500000e+15 0.0 0.6 0.07
19 South Solar plant 0.0 600000.0 25.0 ... 600000.0 1.500000e+15 0.0 0.0 0.07
20 South Wind plant 0.0 200000.0 25.0 ... 1500000.0 1.500000e+15 0.0 0.0 0.07
您可以使用rename_axis https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.rename_axis.html:
df = df.rename_axis(None, axis=1)
# df.columns.name = None
# To remove index label
df = df.rename_axis(None, axis=0)
# df.index.name = None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)