Pandas Timestamp Get Day

Pandas provide us with the day attribute that allows extracting the day from a given timestamp object.


To use this attribute, you need to construct a Timestamp object. You can do this using the timestamp() function as shown:

# import pandas
import pandas as pd
ts = pd.Timestamp('2022-04-04')

The above example creates a Pandas timestamp object from a datetime-time string. The resulting output is as shown:

2022-04-04 00:00:00

You can explore the Pandas timestamp() function in the resource shown:

Extract Day From Timestamp Object

To extract the day from the timestamp object shown above, we can run the code as shown:

print(f"date: {}")

The above should return the day from the provided timestamp object.

Get Day of Week

You can also fetch the day name from a timestamp object using the day_name() function.

An example is as shown:

print(f"day: {ts.day_name()}")


This was a short tutorial depicting how to extract the day and day name from a timestamp object.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list