The Pandas tseries offsets BQuarterBegin 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 BQuarterBegin.is_quarter_start()
is_quarter_start() function
1 import pandas as pd
2
3 offset = pd.tseries.offsets.BQuarterBegin()
4
5 tstamp = pd.Timestamp(2022, 3, 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 month. 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(2023, 3, 1)
4 print('The timestamp object :', tstamp)
5
6 offset = pd.tseries.offsets.BQuarterBegin(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 BQuarterBegin 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 month.
1 The timestamp object : 2023-03-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, 2, 1)
4 print('The timestamp object :', tstamp1)
5
6 offset1 = pd.tseries.offsets.BQuarterBegin(n = 3, startingMonth = 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 BQuarterBegin with normalize as true and startingMonth and unit frequency as 3. A is_quarter_start() function is called by passing a timestamp that determine whether the timestamp occurs at the start of quarter month.
1 The timestamp object : 2024-02-01 00:00:00
2 Does timestamp at start of quarter :True
Related options for your search