简体   繁体   English

如何检查pandas数据框中的每一列是否按升序排列

[英]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.我想知道 pandas 数据框中的每一列是否按升序排列。

**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.对于 col1、col2 和 col3 如何查找哪些列是升序的,哪些列不是。

尝试:

df.apply(lambda x: x.is_monotonic)

is_monotonic is deprecated. is_monotonic已弃用。 Now use:现在使用:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM