w3resource

Pandas Series property: dt.is_quarter_start

Series.dt.is_quarter_start property

The is_quarter_start property is used to check whether a given date is the first day of a quarter or not.

Syntax:

Series.dt.is_quarter_start
Pandas Series: dt.is_quarter_start property

Returns: is_quarter_start : Series or DatetimeIndex
The same type as the original data with boolean values. Series will have the same name and index. DatetimeIndex will have the same name.

Example:

Python-Pandas Code:

import numpy as np
import pandas as pd
df = pd.DataFrame({'dates': pd.date_range("2019-03-30",
                  periods=4)})
df.assign(quarter=df.dates.dt.quarter,
          is_quarter_start=df.dates.dt.is_quarter_start)

Output:

       dates	quarter	is_quarter_start
0	2019-03-30   	1        	False
1	2019-03-31  	1       	False
2	2019-04-01  	2        	True
3	2019-04-02  	2        	False

Python-Pandas Code:

import numpy as np
import pandas as pd
idx = pd.date_range('2019-03-30', periods=4)
idx

Output:

DatetimeIndex(['2019-03-30', '2019-03-31', '2019-04-01', '2019-04-02'], dtype='datetime64[ns]', freq='D')

Python-Pandas Code:

import numpy as np
import pandas as pd
idx = pd.date_range('2019-03-30', periods=4)
idx.is_quarter_start

Output:

array([False, False,  True, False])
Pandas Series: dt.is_quarter_start property

Previous: Series.dt.is_month_end property
Next: Series.dt.is_quarter_end property



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/pandas/series/series-dt-is_quarter_start.php