To find the day of the week from the pandas' Timestamp
object, we use the attribute, .dayofweek
. The Timestamp
object is similar to the Python's datetime
object. Let's see how to find the day of the week.
Timestamp.dayofweek
This attribute does not require any parameter value. It just requires the Timestamp
object to find day of the week for it.
It returns an integer from 0
to 6
representing the day of the week. 0
represents Monday, 1
represents Tuesday, and so on.
# A code to illustrate the .day_of_week attribute in Pandas # importing the pandas library import pandas as pd # creating a Timestamp object a = pd.Timestamp(2020, 4, 19) # (Year, Month, Day) # getting the day of the week print(a.dayofweek)
pandas
library.Timestamp
object, a
. We provide the year, month, and day for Timestamp
. For example, 2020:04:19
.a
using the .dayofweek
attribute.RELATED TAGS
CONTRIBUTOR
View all Courses