How to check each column in pandas data frame are in ascending order or not

Question:

i want to know each column in pandas data frame are in ascending order or not.

**col1** **col2**  **col3**

99   102   103

97   103   107

100   108   109

for col1, col2 and col3 how to find which columns are in ascending order and which columns are not.

Asked By: kk16

||

Answers:

Try:

df.apply(lambda x: x.is_monotonic)
Answered By: Loochie

is_monotonic is deprecated. Now use:

assert df["x"].is_monotonic_increasing
assert df["y"].is_monotonic_increasing
assert df["z"].is_monotonic_increasing
Answered By: HeyMan
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.