Pandas tseries offsets QuarterEnd function is_month_start() in Python
The Pandas tseries offsets QuarterEnd function is_month_start() used to determine whether the timestamp occurs on the month start. It returns a boolean value that specifies whether the timestamp occurs at the start of month.
Syntax
 1 QuarterEnd.is_month_start()
is_month_start() function
 1 import pandas as pd
 2 
 3 offset = pd.tseries.offsets.QuarterEnd()
 4 
 5 tstamp = pd.Timestamp(2022, 6, 1)
 6 res = offset.is_month_start(tstamp)
 7 print(f'Timestamp at month start :{res}')
 8 
 9 tstamp1 = pd.Timestamp(2022, 4, 14)
 10 res1 = offset.is_month_start(tstamp1)
 11 print(f'Timestamp at month start :{res1}')
In the above example, a Timestamp created by passing a date value. A is_month_start() function is called that determine whether a timestamp occurs at the start of month. The result is assign to the variable that will be printed on console.
Output
 1 Timestamp at month start :True
 2 Timestamp at month start :False

Example 2

Example 2
 1 import pandas as pd
 2 
 3 tstamp = pd.Timestamp(2023, 3, 1, 12, 35)
 4 print('The timestamp object :', tstamp)
 5 
 6 offset = pd.tseries.offsets.QuarterEnd(normalize = True)
 7 res = offset.is_month_start(tstamp)
 8 print(f'Timestamp at month start :{res}')
In the above example, a Timestamp created by passing a date value and QuarterEnd with normalize as true. A is_month_start() function is called that determine whether a timestamp occurs at the start of month.
Output
 1 The timestamp object : 2023-03-01 12:35:00
 2 Timestamp at month start :True

Example 3

Example 3
 1 import pandas as pd
 2 
 3 tstamp1 = pd.Timestamp(2024, 4, 1, 11, 45)
 4 print('The timestamp object :', tstamp1)
 5 
 6 offset1 = pd.tseries.offsets.QuarterEnd(n = 3, startingMonth = 4, normalize = True)
 7 res1 = offset1.is_month_start(tstamp1)
 8 print(f'Timestamp at month start :{res1}')
In the above example, a Timestamp created by passing a date value and QuarterEnd with normalize as true, startingMonth as 4 and unit frequency as 3. A is_month_start() function is called that determine whether a timestamp occurs at the start of month.
Output
 1 The timestamp object : 2024-04-01 11:45:00
 2 Timestamp at month start :True
Related options for your search
Privacy Policy
Terms of Service
Disclaimer
Contact us
About us