Python Pandas PeriodIndex.dayinmonth

Python Pandas PeriodIndex.dayinmonth

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

Pandas PeriodIndex.daysinmonth属性返回一个Index对象。该索引包含了给定PeriodIndex对象中每个元素在本月的天数。

语法 :

PeriodIndex.dayinmonth

参数:
返回:指数

示例#1:使用PeriodIndex.daysinmonth属性来查找给定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)

输出 :

Python Pandas PeriodIndex.dayinmonth

现在我们将使用PeriodIndex.daysinmonth属性来查找给定对象中每个元素在本月的天数。

# return the number of days in month
pidx.daysinmonth

输出 :

Python Pandas PeriodIndex.dayinmonth

正如我们在输出中看到的,PeriodIndex.daysinmonth属性已经返回了一个Index对象,包含了给定PeriodIndex对象中每个元素在这个月的天数。

示例#2:使用PeriodIndex.daysinmonth属性来查找给定PeriodIndex对象中每个元素在本月的天数。

# importing pandas as pd
import pandas as pd
 
# Create the PeriodIndex object
pidx = pd.PeriodIndex(start ='2011-02-14 ',
              end ='2011-02-21', freq ='D')
 
# Print the PeriodIndex object
print(pidx)

输出 :

Python Pandas PeriodIndex.dayinmonth

现在我们将使用PeriodIndex.daysinmonth属性来查找给定对象中每个元素在本月的天数。

# return the number of days in month
pidx.daysinmonth

输出 :

Python Pandas PeriodIndex.dayinmonth

正如我们在输出中看到的,PeriodIndex.daysinmonth属性已经返回了一个Index对象,包含了给定PeriodIndex对象中每个元素在这个月的天数。

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程