The Pandas tseries offsets QuarterEnd function is_quarter_end() used to determine whether the timestamp occurs on the quarter end. It returns a boolean value that specifies whether the timestamp occurs at the end of quarter.
1 QuarterEnd.is_quarter_end()
is_quarter_end() function
1 import pandas as pd
2
3 offset = pd.tseries.offsets.QuarterEnd()
4
5 tstamp = pd.Timestamp(2022, 6, 30)
6 res = offset.is_quarter_end(tstamp)
7 print(f'Timestamp at quarter month end :{res}')
8
9 tstamp1 = pd.Timestamp(2022, 5, 31)
10 res1 = offset.is_quarter_end(tstamp1)
11 print(f'Timestamp at quarter month end :{res1}')
In the above example, a Timestamp created by passing a date value. A is_quarter_end() function is called that determine whether a timestamp occurs at the end of quarter month. The result is assign to the variable that will be printed on console.
1 Timestamp at quarter month end :True
2 Timestamp at quarter month end :False
Example 2
1 import pandas as pd
2
3 tstamp = pd.Timestamp(2023, 3, 31)
4 print('The timestamp object :', tstamp)
5
6 offset = pd.tseries.offsets.QuarterEnd(normalize = True)
7 res = offset.is_quarter_end(tstamp)
8 print(f'Timestamp at quarter month end :{res}')
In the above example, a Timestamp created by passing a date value and QuarterEnd with normalize as true. A is_quarter_end() function is called that determine whether a timestamp occurs at the end of quarter month.
1 The timestamp object : 2023-03-31 00:00:00
2 Timestamp at quarter month end :True
Example 3
1 import pandas as pd
2
3 tstamp1 = pd.Timestamp(2024, 7, 31)
4 print('The timestamp object :', tstamp1)
5
6 offset1 = pd.tseries.offsets.QuarterEnd(n = 3, startingMonth = 4, normalize = True)
7 res = offset.is_quarter_end(tstamp)
8 print(f'Timestamp at quarter month end :{res}')
In the above example, a Timestamp created by passing a date value and QuarterEnd with normalize as true, unit frequency as 3 and startingMonth as 4. A is_quarter_end() function is called that determine whether a timestamp occurs at the end of quarter month.
1 The timestamp object : 2024-07-31 00:00:00
2 Timestamp at quarter month end :True
Related options for your search