當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


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)

輸出:

現在,我們將檢查TimedeltaIndex對象是否單調遞減。

# check if tidx is monotonic decreasing or not 
tidx.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)

輸出:

現在,我們將檢查TimedeltaIndex對象是否單調遞減。

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

輸出:

正如我們在輸出中看到的,TimedeltaIndex.is_monotonic_decreasing屬性已返回False指示tidx對象中的值不是單調遞減。



相關用法


注:本文由純淨天空篩選整理自Shubham__Ranjan大神的英文原創作品 Python | Pandas TimedeltaIndex.is_monotonic_decreasing。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。