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 libraryimport pandas as pd# creating a Timestamp objecta = pd.Timestamp(2020, 4, 19) # (Year, Month, Day)# getting the day of the weekprint(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.