Python Pandas TimedeltaIndex.is_monotonic_decreasing

Python Pandas TimedeltaIndex.is_monotonic_decreasing

Python是一种进行数据分析的伟大语言,主要是因为以数据为中心的Python包的奇妙生态系统。Pandas就是这些包中的一个,它使导入和分析数据变得更加容易。

Pandas TimedeltaIndex.is_monotonic_decreasing属性在索引值是单调递减时返回True。即使数值相等,也会返回True。

语法: TimedeltaIndex.is_monotonic_decreasing

返回 : 布尔值

例子#1:使用TimedeltaIndex.is_monotonic_decreasing属性来检查TimedeltaIndex对象是否是单调递减。

# importing pandas as pd
import pandas as pd
  
# Create the TimedeltaIndex object
tidx = pd.TimedeltaIndex(data =['1 days 02:04:00', '1 days 02:03:00', 
                               '1 days 02:02:00', '1 days 02:01:00'])
  
# Print the TimedeltaIndex
print(tidx)

输出 :
Python Pandas TimedeltaIndex.is_monotonic_decreasing
现在我们将检查TimedeltaIndex对象是否是单调递减的。

# check if tidx is monotonic decreasing or not
tidx.is_monotonic_decreasing

输出 :
Python Pandas TimedeltaIndex.is_monotonic_decreasing
正如我们在输出中看到的,TimedeltaIndex.is_monotonic_decreasing属性返回了True,表明tidx对象的值是单调递减的。

例子#2:使用TimedeltaIndex.is_monotonic_decreasing属性来检查TimedeltaIndex对象是否是单调递减。

# importing pandas as pd
import pandas as pd
  
# Create the TimedeltaIndex object
tidx = pd.TimedeltaIndex(data =['-1 days 2 min 3us', '1 days 06:05:01.000030',
                                                 '-1 days + 23:59:59.999999'])
  
# Print the TimedeltaIndex
print(tidx)

输出 :
Python Pandas TimedeltaIndex.is_monotonic_decreasing

现在我们将检查TimedeltaIndex对象是否是单调递减的。

# check if tidx is monotonic decreasing or not
tidx.is_monotonic_decreasing

输出 :
Python Pandas TimedeltaIndex.is_monotonic_decreasing
正如我们在输出中看到的,TimedeltaIndex.is_monotonic_decreasing属性返回了False,表明tidx对象的值不是单调递减的。

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

Pandas 日期时间