In my data set in height
column value increases then after starts to decrease. 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:
x = df.idmax()['height']
df = df.iloc[:x+1]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.