Pandas Series property: dt.is_quarter_end
Series.dt.is_quarter_end property
The is_quarter_end property is used to check whether a given date is the last day of a quarter or not.
Syntax:
Series.dt.is_quarter_end
Returns: is_quarter_end : 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_end=df.dates.dt.is_quarter_end)
Output:
dates quarter is_quarter_end 0 2019-03-30 1 False 1 2019-03-31 1 True 2 2019-04-01 2 False 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_end
Output:
array([False, True, False, False])
Previous: Series.dt.is_quarter_start property
Next: Series.dt.is_year_start 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://www.w3resource.com/pandas/series/series-dt-is_quarter_end.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics