在大 pandas DataFrame中重新分配索引 [英] Reassigning index in pandas DataFrame
本文介绍了在大 pandas DataFrame中重新分配索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
0,1,...,n-1
,但现在它们是乱序的。如何将这些索引重新分配给新排序的DataFrame的正确顺序?解决方案
df .reset_index(drop = True,inplace = True)
I'm fairly sure this is a duplicate, but suppose I have a pandas DataFrame and I've sorted the rows based on the values of some column. Originally the indices were the integers 0, 1, …, n-1
but now they're out of order. How do I reassign these indices to be in the proper order for the new sorted DataFrame?
解决方案
df.reset_index(drop=True, inplace=True)
这篇关于在大 pandas DataFrame中重新分配索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文