Python | Панды Series.dt.is_quarter_end
Series.dt can be used to access the values of the series as datetimelike and return several properties. Pandas Series.dt.is_quarter_end attribute return a boolean value Indicating whether the date is the last day of a quarter.
Syntax: Series.dt.is_quarter_end
Parameter : None
Returns : numpy array
Example #1: Use Series.dt.is_quarter_end attribute to check if the dates in the underlying data of the given series object is the last day of the quarter.
Output :
Now we will use Series.dt.is_quarter_end attribute to check if the dates in the given series object is the last day of the quarter or not.
# check if dates are the last # day of the quarterresult = sr.dt.is_quarter_end # print the resultprint(result) |
Output :
As we can see in the output, the Series.dt.is_quarter_end attribute has successfully accessed and returned boolean values indicating whether the dates are the last day of the quarter or not.
Example #2 : Use Series.dt.is_quarter_end attribute to check if the dates in the underlying data of the given series object is the last day of the quarter.
# importing pandas as pdimport pandas as pd # Creating the Seriessr = pd.Series(pd.date_range("2012-1-1 00:00", periods = 5, freq = "Q")) # Creating the indexidx = ["Day 1", "Day 2", "Day 3", "Day 4", "Day 5"] # set the indexsr.index = idx # Print the seriesprint(sr) |
Output :
Now we will use Series.dt.is_quarter_end attribute to check if the dates in the given series object is the last day of the quarter or not.
# check if dates are the last # day of the quarterresult = sr.dt.is_quarter_end # print the resultprint(result) |
Output :
As we can see in the output, the Series.dt.is_quarter_end attribute has successfully accessed and returned boolean values indicating whether the dates are the last day of the quarter or not.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course