📜  Python| Pandas Timestamp.is_quarter_end

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

Python| Pandas Timestamp.is_quarter_end

Python是一种用于进行数据分析的出色语言,主要是因为以数据为中心的Python包的奇妙生态系统。 Pandas就是其中之一,它使导入和分析数据变得更加容易。

Pandas Timestamp.is_quarter_end属性返回一个布尔值。如果给定 Timestamp 对象中的日期是季度末,则返回True ,否则返回False

示例 #1:使用Timestamp.is_quarter_end属性检查给定 Timestamp 对象中的日期是否为季度结束。

# importing pandas as pd
import pandas as pd
  
# Create the Timestamp object
ts = pd.Timestamp(2016, 3, 31, 12)
  
# Print the Timestamp object
print(ts)

输出 :

现在我们将使用Timestamp.is_quarter_end属性来检查 ts 对象中的日期是否是季度结束。

# check if the date is quarter end or not
ts.is_quarter_end

输出 :

正如我们在输出中看到的, Timestamp.is_quarter_end属性返回True ,表示给定 Timestamp 对象中的日期是季度结束

示例 #2:使用Timestamp.is_quarter_end属性检查给定 Timestamp 对象中的日期是否为季度结束。

# importing pandas as pd
import pandas as pd
  
# Create the Timestamp object
ts = pd.Timestamp(year = 2009, month = 5, day = 31,
                    hour = 4, tz = 'Europe/Berlin')
  
# Print the Timestamp object
print(ts)

输出 :

现在我们将使用Timestamp.is_quarter_end属性来检查 ts 对象中的日期是否是季度结束。

# check if the date is quarter end or not
ts.is_quarter_end

输出 :

正如我们在输出中看到的, Timestamp.is_quarter_end属性返回False ,表示给定 Timestamp 对象中的日期不是季度结束。