Open In App

Python | Pandas DatetimeIndex.is_quarter_start

Improve
Improve
Like Article
Like
Save
Share
Report

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_quarter_start attribute is an indicator for whether the date is the first day of a quarter. If the date is the first day of the quarter it returns True else it return False.

Syntax: DatetimeIndex.is_quarter_start

Returns: numpy array containing logical values.

Example #1: Use DatetimeIndex.is_quarter_start attribute to check if the dates present in the DatetimeIndex object is the first day of the quarter.




# importing pandas as pd
import pandas as pd
  
# Create the DatetimeIndex
didx = pd.DatetimeIndex(['2014-01-31', '2014-04-1', '2015-08-01', '2000-12-02'])
  
# Print the DatetimeIndex
print(didx)


Output :

Now we want to find if the dates contained in the given DatetimeIndex object is the first day of the quarter.




# find if the days are the first day of the quarter.
didx.is_quarter_start


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 first day of the quarter and False value indicate the corresponding date was not the first day of the quarter.
 
Example #2: Use DatetimeIndex.is_quarter_start attribute to check if the dates present in the DatetimeIndex object is the first day of the quarter.




# importing pandas as pd
import pandas as pd
  
# Create the DatetimeIndex
didx = pd.date_range('2011-03-30', periods = 5)
  
# Print the DatetimeIndex
print(didx)


Output :

Now we want to find if the dates contained in the given DatetimeIndex object is the first day of the quarter.




# find if the days are the first day of the quarter.
didx.is_quarter_start


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 first day of the quarter and False value indicate the corresponding date was not the first day of the quarter.



Last Updated : 24 Dec, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads