To return the count of increments applied on the BusinessDay offset, use the BusinessDay.n property in Pandas.
At first, import the required libraries −
import datetime import pandas as pd
Set the timestamp object in Pandas” −
timestamp = pd.Timestamp('2021-10-30 01:55:02.000045')
Create the BusinessDay Offset. BusinessDay is the DateOffset subclass −
bdOffset = pd.tseries.offsets.BusinessDay(n = 6)
Display the Updated Timestamp −
print("\nUpdated Timestamp...\n",timestamp + bdOffset)
Return the count of increments on the given BusinessDay object −
print("\nThe count of increments on the BusinessDay object..\n", bdOffset.n)Example
Following is the code −
import datetime
import pandas as pd
# Set the timestamp object in Pandas
timestamp = pd.Timestamp('2021-10-30 01:55:02.000045')
# Display the Timestamp
print("Timestamp...\n",timestamp)
# Create the BusinessDay Offset
# BusinessDay is the DateOffset subclass
bdOffset = pd.tseries.offsets.BusinessDay(n = 6)
# Display the BusinessDay Offset
print("\nBusinessDay Offset...\n",bdOffset)
# Display the Updated Timestamp
print("\nUpdated Timestamp...\n",timestamp + bdOffset)
# return the frequency applied on the given BusinessDay object as a string
print("\nFrequency on the given BusinessDay Offset...\n",bdOffset.freqstr)
# return the count of increments on the given BusinessDay object
print("\nThe count of increments on the BusinessDay object..\n", bdOffset.n)Output
This will produce the following code −
Timestamp... 2021-10-30 01:55:02.000045 BusinessDay Offset... <6 * BusinessDays> Updated Timestamp... 2021-11-08 01:55:02.000045 Frequency on the given BusinessDay Offset... 6B The count of increments on the BusinessDay object.. 6