[英]sort Pandas Dataframe based on column value
enter image description here 在此处输入图片说明
In my data set in height
column value increases then after starts to decrease. 在我的
height
数据集中,列值增加,然后开始减少。 I want to sort data only up to increase height. 我只想对数据进行排序以增加高度。 I don't want data after height decrease.
高度降低后,我不需要数据。
You can achieve this by finding the index of the max value of the height
column, and then using iloc
to reassign the dataframe only including the rows up to this index: 您可以通过找到
height
列的最大值的索引,然后使用iloc
重新分配仅包括该索引行的数据iloc
来实现此目的:
x = df.idmax()['height']
df = df.iloc[:x+1]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.