w3resource

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
Pandas Series: dt.is_quarter_end property

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])
Pandas Series: dt.is_quarter_end property

Previous: Series.dt.is_quarter_start property
Next: Series.dt.is_year_start property



Follow us on Facebook and Twitter for latest update.