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
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])
Previous: Series.dt.is_month_end property
Next: Series.dt.is_quarter_end property
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://w3resource.com/pandas/series/series-dt-is_quarter_start.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics