Pandas 文档 - 索引
Pandas Documentation - indexing
我在这个 Whosebug 答案中找到了关于如何反转 python 系列顺序的答案。
他们将此页面作为来源引用:http://pandas.pydata.org/pandas-docs/stable/indexing.html,但我无法在该页面上找到解释反向索引策略的确切部分。有人可以帮我解决这个问题,或者指导我在 pandas/python 文档中概述该策略的位置。
我认为您应该阅读有关切片的内容:
Understanding Python's slice notation
有关反转 df 的不同方法,请查看此处:Right way to reverse pandas.DataFrame?
如果您只是想反转索引顺序以保持数据顺序不变,请尝试
df.index = reversed(df.index)
对于可能正在搜索此内容的任何其他人,上面的答案提供了非常好的 link 来解释这个概念:Understanding Python's slice notation
作为问题的答案"Where in the documentation does it say this?"
Python 文档在此处解释了基本切片:
Basic Slicing in Documentation
然后在 python 2.3 的更新中解释了步骤(或增量)的功能
Slicing with steps explained
我在这个 Whosebug 答案中找到了关于如何反转 python 系列顺序的答案。
他们将此页面作为来源引用:http://pandas.pydata.org/pandas-docs/stable/indexing.html,但我无法在该页面上找到解释反向索引策略的确切部分。有人可以帮我解决这个问题,或者指导我在 pandas/python 文档中概述该策略的位置。
我认为您应该阅读有关切片的内容: Understanding Python's slice notation
有关反转 df 的不同方法,请查看此处:Right way to reverse pandas.DataFrame?
如果您只是想反转索引顺序以保持数据顺序不变,请尝试
df.index = reversed(df.index)
对于可能正在搜索此内容的任何其他人,上面的答案提供了非常好的 link 来解释这个概念:Understanding Python's slice notation
作为问题的答案"Where in the documentation does it say this?" Python 文档在此处解释了基本切片: Basic Slicing in Documentation
然后在 python 2.3 的更新中解释了步骤(或增量)的功能 Slicing with steps explained