Python Pandas PeriodIndex.qyear

Python Pandas PeriodIndex.qyear

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

Pandas PeriodIndex.qyear属性会返回一个索引对象,其中包含根据起始季度确定的该周期所在的财政年度。如果财政年度和日历年度是相同的,那么该时期的年份和qyear将是相同的。当它们不一致时,财政年度可以与该时期的日历年度不同。

语法 : PeriodIndex.qyear

参数:

返回:索引对象

示例#1:使用PeriodIndex.qyear属性来找出给定PeriodIndex对象中每个时期的财政年度。

# importing pandas as pd
import pandas as pd
  
# Create the PeriodIndex object
pidx = pd.PeriodIndex(start ='2003-4-21 08:45 ',
             end ='2004-11-21 8:55', freq ='Q')
  
# Print the PeriodIndex object
print(pidx)

输出 :
Python Pandas PeriodIndex.qyear

现在我们将使用PeriodIndex.qyear属性来找出pidx中每个时期的财政年度。

# return the fiscal year of the period
pidx.qyear

输出 :
Python Pandas PeriodIndex.qyear
正如我们在输出中看到的,PeriodIndex.qyear属性已经返回了一个包含给定PeriodIndex对象的每个时期的财政年度的索引对象。

例子2:使用PeriodIndex.qyear属性来找出给定PeriodIndex对象中每个时期的财政年度。

# importing pandas as pd
import pandas as pd
  
# Create the PeriodIndex object
pidx = pd.PeriodIndex(start ='2016-8-12 11:32', 
            end ='2017-04-05 11:55', freq ='M')
  
# Print the PeriodIndex object
print(pidx)

输出 :
Python Pandas PeriodIndex.qyear

现在我们将使用PeriodIndex.qyear属性来找出pidx中每个时期的财政年度。

# return the fiscal year of the period
pidx.qyear

输出 :
Python Pandas PeriodIndex.qyear
正如我们在输出中看到的,PeriodIndex.qyear属性已经返回了一个包含给定PeriodIndex对象的每个时期的财政年度的索引对象。

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程