The Pandas attribute Timestamp.weekday_name
returns the day of the week for a given date in a Timestamp object.
Syntax: Timestamp.weekday_name
Parameters: None
Return: name of the week day
Example # 1: Use the Timestamp.weekday_name
attribute to find the day of the week name for a given date in a Timestamp object.
# import pandas as pd
import
pandas as pd
# Create Timestamp object
ts
=
pd.Timestamp (year
=
2011
, month =
11
, day
=
21
,
hour
=
10
, second
=
49
, tz
=
’US / Central’
)
# Print Timestamp object
print
(ts)
Output:
We will now use the Timestamp.weekday_name attribute to find the name of the day of the week.
# return the name of the day of the week
ts.weekday_name
Output:
As we can see from the output, the Timestamp.weekday_name
attribute returned "Monday", which indicates that the date in this Timestamp is — Monday.
Example # 2: Use the Timestamp.weekday_name
attribute to find the name of the day of the week for a given date in a Timestamp object.
# import pandas as pd
import
pandas as pd
# Create object Timestamp
ts
=
pd.Timestamp ( year
=
2009
, month
=
5
, day
=
31
,
hour
=
4
, second
=
49
, tz
=
’ Europe / Berlin’
)
# Print the Timestamp object
print
(ts)
Output:
We will now use the Timestamp.weekday_name
attribute to find the name of the day of the week.
|
Output:
Like us we can see in the output that the Timestamp.weekday_name
attribute returned & # 39; Sunday & # 39;, indicating that the date in this Timestamp object is & # 39; Sunday & # 39 ;.