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