pandas 使用熊猫反转数据框的行顺序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35240528/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 00:38:29  来源:igfitidea点击:

reverse dataframe's rows' order with pandas

pythonpandasdata-analysis

提问by valentin

How can I reverse the order of the rows in my pandas.dataframe?

如何反转我的pandas.dataframe中的行顺序

I've looked everywhere and the only thing people are talking about is sorting the columns, reversing the order of the columns...

我到处看,唯一的事情人们都在谈论的排序,扭转了顺序...

What I want is simple :

我想要的很简单:

If my DataFrame looks like this:

如果我的 DataFrame 看起来像这样:

   A      B     C
 ------------------
  LOVE    IS   ALL
  THAT   MAT   TERS

I want it to become this:

我希望它变成这样:

   A      B     C
 ------------------
  THAT   MAT   TERS
  LOVE    IS   ALL

I know I can iterate over my data in reverse order but that's not what I want.

我知道我可以以相反的顺序迭代我的数据,但这不是我想要的。

回答by Mike Graham