Python | Pandas DatetimeIndex.is_quarter_end

DatetimeIndex.is_quarter_end Pandas DatetimeIndex.is_quarter_end is an indicator of whether the date is the last day of the quarter. If the date is the last day of the quarter it returns True otherwise it returns False .

Syntax: DatetimeIndex. is_quarter_end

Returns: numpy array containing logical values.

Example # 1: Use the attribute DatetimeIndex.is_quarter_end to check if the dates in the DatetimeIndex are the last day of the quarter.

# import pandas as pd

import pandas as pd

 
# Create DatetimeIndex

didx = pd.DatetimeIndex ([ `2014-01-31` , ` 2014-04-30` , `2017-03-31` , `2000-12-02` ])

 
# Print DatetimeIndex

print (didx)

Output:

Now we want to find out if the dates are contained in this DatetimeIndex object as the last day of the quarter.

# determine if days are the last day of the quarter.
didx.is_quarter_end

Exit:

As we can see in the output, the function returned an empty array containing boolean values ​​for each entry in the DatetimeIndex object.  True values ​​indicate that the corresponding date was the last day of the quarter, and False values ​​indicate that the corresponding date was not the last day of the quarter.

Example # 2: Use the DatetimeIndex.is_quarter_end attribute to check if the dates in the DatetimeIndex are the last day of the quarter.

# import pandas as pd

import pandas as pd

 
# Create DatetimeIndex

idx = pd.date_range ( `2011-03-30` , periods = 5 )

 

 
# Print DatetimeIndex

print (didx)

Output:

Now we want to find out whether the dates contained in this DatetimeIndex are the last day of the quarter.

# determine if days are the last day of the quarter.
didx.is_quarter_end

Output:

As we can see in the output, the function returned an empty array containing boolean values ​​for each entry in the DatetimeIndex object.  True values ​​indicate that the corresponding date was the last day of the quarter, and False values ​​indicate that the corresponding date was not the last day of the quarter.