📜  Python| Pandas PeriodIndex.daysinmonth

📅  最后修改于: 2022-05-13 01:54:40.904000             🧑  作者: Mango

Python| Pandas PeriodIndex.daysinmonth

Python是一种用于进行数据分析的出色语言,主要是因为以数据为中心的Python包的奇妙生态系统。 Pandas就是其中之一,它使导入和分析数据变得更加容易。

Pandas PeriodIndex.daysinmonth属性返回一个 Index 对象。 Index 包含给定 PeriodIndex 对象中每个元素的月份天数。

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

Python3
# 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)


Python3
# return the number of days in month
pidx.daysinmonth


Python3
# 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)


Python3
# return the number of days in month
pidx.daysinmonth


输出 :

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

Python3

# return the number of days in month
pidx.daysinmonth

输出 :

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

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

Python3

# 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)

输出 :

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

Python3

# return the number of days in month
pidx.daysinmonth

输出 :

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