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 libraryimport pandas as pd# creating a Timestamp objecta = pd.Timestamp(2020, 4, 19)# getting the day of the yearprint(a.dayofyear)
pandas
library.a
.a
using the .dayofyear
attribute.