kk16
kk16

Reputation: 35

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

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.

Upvotes: 0

Views: 1290

Answers (2)

HeyMan
HeyMan

Reputation: 1855

is_monotonic is deprecated. Now use:

assert df["x"].is_monotonic_increasing
assert df["y"].is_monotonic_increasing
assert df["z"].is_monotonic_increasing

Upvotes: 1

Loochie
Loochie

Reputation: 2472

Try:

df.apply(lambda x: x.is_monotonic)

Upvotes: 1

Related Questions