Python | Pandas DatetimeIndex.is_year_end
Last Updated :
24 Dec, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas DatetimeIndex.is_year_end
attribute is an indicator for whether the date is the last day of the year. If the date is the last day of the year it returns True
else it return False
.
Syntax: DatetimeIndex.is_year_end
Returns: numpy array containing logical values.
Example #1: Use DatetimeIndex.is_year_end
attribute to check if the dates present in the DatetimeIndex object is the last day of the year.
import pandas as pd
didx = pd.DatetimeIndex([ '2014-01-01' , '2014-12-31' , '2017-03-31' , '2000-12-31' ])
print (didx)
|
Output :
Now we want to find if the dates contained in the given DatetimeIndex object is the last day of the year.
Output :
As we can see in the output, the function has returned a numpy array containing logical values for each entry of the DatetimeIndex object. True
values indicate the corresponding date was the last day of the year and False
value indicate the corresponding date was not the last day of the year.
Example #2: Use DatetimeIndex.is_year_end
attribute to check if the dates present in the DatetimeIndex object is the last day of the year.
import pandas as pd
didx = pd.date_range( "2017-12-30" , periods = 5 )
print (didx)
|
Output :
Now we want to find if the dates contained in the given DatetimeIndex object is the last day of the year.
Output :
As we can see in the output, the function has returned a numpy array containing logical values for each entry of the DatetimeIndex object. True
values indicate the corresponding date was the last day of the year and False
value indicate the corresponding date was not the last day of the year.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...