Python Pandas PeriodIndex.freq
Python是一种进行数据分析的伟大语言,主要是因为以数据为中心的Python软件包的奇妙生态系统。Pandas就是这些包中的一个,使导入和分析数据变得更加容易。
Pandas PeriodIndex.freq属性返回应用于给定PeriodIndex对象的时间序列频率。
语法 :
PeriodIndex.freq
参数:无
返回:index
例子#1:使用PeriodIndex.freq属性来查找给定PeriodIndex对象的时间序列频率。
# importing pandas as pd
import pandas as pd
# Create the PeriodIndex object
pidx = pd.PeriodIndex(start='2005-12-21 08:45 ',
end='2005-12-21 11:55', freq='H')
# Print the PeriodIndex object
print(pidx)
输出 :
现在我们将使用PeriodIndex.freq属性来查找给定对象的时间序列频率。
# return the frequency
pidx.freq
输出 :
正如我们在输出中看到的,PeriodIndex.freq属性已经返回了’Hourly’频率。这是应用于给定PeriodIndex对象的时间序列频率。
例子#2:使用PeriodIndex.freq属性来查找给定PeriodIndex对象的时间序列频率。
# importing pandas as pd
import pandas as pd
# Create the PeriodIndex object
pidx = pd.PeriodIndex(start='2011-02-1 ',
end='2011-08-14', freq='M')
# Print the PeriodIndex object
print(pidx)
输出 :
现在我们将使用PeriodIndex.freq属性来查找给定对象的时间序列频率。
# return the frequency
pidx.freq
输出 :
正如我们在输出中看到的,PeriodIndex.freq属性已经返回了’Monthly’频率。这是应用于给定PeriodIndex对象的时间序列频率。