0

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.

kk16
  • 35
  • 5
  • 2
    I think your question has already been answered here https://stackoverflow.com/questions/28093365/is-a-column-in-pandas-df-monotonically-increasing – MaximGi Mar 24 '19 at 09:50
  • 1
    Possible duplicate of [Is a column in pandas.DF() monotonically increasing?](https://stackoverflow.com/questions/28093365/is-a-column-in-pandas-df-monotonically-increasing) – Jondiedoop Mar 24 '19 at 09:54

2 Answers2

1

Try:

df.apply(lambda x: x.is_monotonic)
Loochie
  • 2,414
  • 13
  • 20
0

is_monotonic is deprecated. Now use:

assert df["x"].is_monotonic_increasing
assert df["y"].is_monotonic_increasing
assert df["z"].is_monotonic_increasing
HeyMan
  • 1,529
  • 18
  • 32