a concise shot of dev knowledge
Become a Contributor
Concise shots of dev knowledge

RELATED TAGS

pandas
communitycreator

What is the Period.dayofweek() attribute in pandas?

Onyejiaku Theophilus Chidalu

Overview

The dayofweek() attribute in pandas is used to obtain the day of the week the given Period lies in. Monday is given as 0, Tuesday is given as 1, Wednesday is given as 2, and so on and so forth.

Syntax

Period.dayofweek
Syntax for the dayofweek attribute in Pandas

Parameters

The dayofweek, being an attribute, takes no parameter value.

Return value

The dayofweek attribute returns an integer representing the day of week from the given Period object.

Example

# A code to illustrate the dayofweek attribute
# importing the pandas library
import pandas as pd

# creating a Period object
a = pd.Period('2022-5-2 8:00', 'H')

# printing the day of the week
print(a.dayofweek)
Implementing the daysofweek attribute

Explanation

  • Line 3: We import the pandas library.
  • Line 6: We create a Period object, a.
  • Line 9: We obtain the day of the week from the input, Period object, using the dayofweek attribute. We print the value to the console.

RELATED TAGS

pandas
communitycreator

CREATOR

Onyejiaku Theophilus Chidalu
RELATED COURSES

View all Courses

Keep Exploring

Learn in-demand tech skills in half the time

Copyright ©2022 Educative, Inc. All rights reserved.

soc2