📜  Python| Pandas Index.is_monotonic_decreating

📅  最后修改于: 2022-05-13 01:54:31.673000             🧑  作者: Mango

Python| Pandas Index.is_monotonic_decreating

Pandas Index 是一个不可变的 ndarray,它实现了一个有序的、可切片的集合。它是存储所有 pandas 对象的轴标签的基本对象。

如果给定 Index 对象中的基础数据单调递减,则 Pandas Index.is_monotonic_decreasing属性返回True ,否则返回False

示例 #1:使用Index.is_monotonic_decreasing属性来确定给定 Index 对象中的基础数据是否单调递减。

# importing pandas as pd
import pandas as pd
  
# Creating the index
idx = pd.Index([900, 700, 620, 388, 24])
  
# Print the index
print(idx)

输出 :

现在我们将使用Index.is_monotonic_decreasing属性来确定给定 Index 对象中的基础数据是否单调递减。

# check if the values in the Index
# are monotonically decreasing 
result = idx.is_monotonic_decreasing
  
# Print the result
print(result)

输出 :

正如我们在输出中看到的那样, Index.is_monotonic_decreasing属性返回True ,表明给定 Index 对象的基础数据是单调递减的。示例 #2:使用Index.is_monotonic_decreasing属性来确定给定 Index 对象中的基础数据是否单调递减。

# importing pandas as pd
import pandas as pd
  
# Creating the index
idx = pd.Index(['2012-12-12', None, '2002-1-10', None])
  
# Print the index
print(idx)

输出 :

现在我们将使用Index.is_monotonic_decreasing属性来确定给定 Index 对象中的基础数据是否单调递减。

# check if the values in the Index
# are monotonically decreasing 
result = idx.is_monotonic_decreasing
  
# Print the result
print(result)

输出 :

正如我们在输出中看到的那样, Index.is_monotonic_decreasing属性返回了False ,表明给定 Index 对象的基础数据不是单调递减的。