删除行索引数据框 pandas [英] Remove Row Index dataframe pandas
本文介绍了删除行索引数据框 pandas 的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给出一个df
in[0]df1
out[0]
DATE REVENUE COST POSITION
FACTOR
0 2017/01/01 1000 900 10
1 2017/01/01 900 700 9
2 2017/01/01 1100 800 7
我还有另外一行FACTOR
.在尝试使用reset_index()
和其他方法之后,我无法删除FACTOR
多重(行)索引.有办法吗?
I have an additional row FACTOR
. After trying reset_index()
and other ways, I cannot remove the FACTOR
multi (row) index. Is there a way to do so?
我知道删除列并重置索引是很常见的,但是这种方式并非如此.
I know it's common to drop columns and reset index but not this way though.
推荐答案
我希望这可行:)
df.reset_index(inplace=True) # Resets the index, makes factor a column
df.drop("Factor",axis=1,inplace=True) # drop factor from axis 1 and make changes permanent by inplace=True
这篇关于删除行索引数据框 pandas 的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文