Python Pandas PeriodIndex.dayofweek

Python Pandas PeriodIndex.dayofweek

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

Pandas PeriodIndex.dayofweek属性返回一个Index对象,其中包含给定PeriodIndex对象中每个元素的工作日的值。’0’是一周的第一天,’6’是一周的最后一天。

语法 :

PeriodIndex.dayofweek

参数:
返回:指数

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

现在我们将使用PeriodIndex.dayofweek属性来查找给定对象中每个元素的星期数的值。

# return the value of days of the week
pidx.dayofweek

输出 :

Python Pandas PeriodIndex.dayofweek

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

例子#2:使用PeriodIndex.dayofweek属性来查找给定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)

输出 :

Python Pandas PeriodIndex.dayofweek

现在我们将使用PeriodIndex.dayofweek属性来查找给定对象中每个元素的星期数的值。

# return the value of days of the week
pidx.dayofweek

输出 :

Python Pandas PeriodIndex.dayofweek

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

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程