Python Pandas Period.qyear
Python是一种进行数据分析的伟大语言,主要是因为以数据为中心的Python包的奇妙生态系统。Pandas就是这些包中的一个,它使导入和分析数据变得更加容易。
Pandas Period.qyear属性根据其起始季度返回该周期所在的财政年度。如果财政年度和日历年度是相同的,那么该时期的年份和qyear将是相同的。当它们不一致时,财政年度可以与该时期的日历年度不同。
语法 : Period.qyear
参数:无
回报率:财政年度
示例#1:使用Period.qyear属性来查找给定的Period对象中的财政年度。
# importing pandas as pd
import pandas as pd
# Create the Period object
prd = pd.Period(freq ='S', year = 2000, month = 2,
day = 21, hour = 8, minute = 21)
# Print the Period object
print(prd)
输出 :

现在我们将使用Period.qyear属性来查找财政年度。
# return the fiscal year
prd.qyear
输出 :

正如我们在输出中看到的,Period.qyear属性返回2000,表明给定的时期位于2000年。
例子2:使用Period.qyear属性来查找给定的Period对象中的财政年度。
# importing pandas as pd
import pandas as pd
# Create the Period object
prd = pd.Period(freq ='T', year = 2006, month = 10,
hour = 15, minute = 49)
# Print the Period object
print(prd)
输出 :

现在我们将使用Period.qyear属性来查找财政年度。
# return the fiscal year
prd.qyear
输出 :

正如我们在输出中看到的,Period.qyear属性返回了2006,表明给定的时期位于2006年。
极客教程