Python Pandas PeriodIndex.dayofyear
Python是一种进行数据分析的伟大语言,主要是因为以数据为中心的Python软件包的奇妙生态系统。Pandas就是这些包中的一个,使导入和分析数据变得更加容易。
Pandas PeriodIndex.dayofyear属性返回一个索引对象。该索引包含给定PeriodIndex对象中每个元素的年的序号。
语法 :
PeriodIndex.dayofyear
参数:无
例子#1:使用PeriodIndex.dayofyear属性来查找给定PeriodIndex对象中每个元素的年序天数的值。
# importing pandas as pd
import pandas as pd
# Create the PeriodIndex object
pidx = pd.PeriodIndex(start ='2005-12-21',
end ='2005-12-29', freq ='D')
# Print the PeriodIndex object
print(pidx)
输出 :
现在我们将使用PeriodIndex.dayofyear属性来查找给定对象中每个元素的年序天数的值。
# return the value of ordinal
# days of the year
pidx.dayofyear
输出 :
正如我们在输出中看到的,PeriodIndex.dayofyear属性返回了一个Index对象,其中包含给定PeriodIndex对象中每个元素的年序天数的值。
示例#2:使用PeriodIndex.dayofyear属性来查找给定PeriodIndex对象中每个元素的年序天数的值。
# importing pandas as pd
import pandas as pd
# Create the PeriodIndex object
pidx = pd.PeriodIndex(start ='2011-03-14 ',
end ='2011-03-21', freq ='D')
# Print the PeriodIndex object
print(pidx)
输出 :
现在我们将使用PeriodIndex.dayofyear属性来查找给定对象中每个元素的年序天数的值。
# return the value of ordinal
# days of the year
pidx.dayofyear
输出 :
正如我们在输出中看到的,PeriodIndex.dayofyear属性返回了一个Index对象,其中包含了给定PeriodIndex对象中每个元素的年序天数的值。