To obtain the date of the year from the Pandas' Timestamp
object, which is an equivalent of Python's datetime object, we make use of the .dayofyear
attribute.
Timestamp.dayofyear
This attribute does not take any parameter value.
It returns an integer representing the day of the year.
# A code to illustrate the .daysofyear attribute in Pandas # importing the pandas library import pandas as pd # creating a Timestamp object a = pd.Timestamp(2020, 4, 19) # getting the day of the year print(a.dayofyear)
pandas
library.a
.a
using the .dayofyear
attribute.RELATED TAGS
CONTRIBUTOR
View all Courses