📅  最后修改于: 2023-12-03 15:19:16.330000             🧑  作者: Mango
tseries.offsets.CustomBusinessDay.name
Pandas is a powerful library for data manipulation and analysis. Tseries module in Pandas provides time series functionality for various frequencies. In this article, we will discuss tseries.offsets.CustomBusinessDay.name
from the offset module.
Syntax:
pandas.tseries.offsets.CustomBusinessDay(name=None, weekmask='Mon Tue Wed Thu Fri', holidays=None, calendar=None, normalize=False, offset=None)
The CustomBusinessDay
offset returns a set of business days of custom frequency. It is a subclass of pd.tseries.offsets.CustomBusinessDay
. The name
parameter is used to refer to this custom business day object.
Parameters:
24/7
) offset, anchored to midnight.Return type: pandas.tseries.offsets.CustomBusinessDay
import pandas as pd
from datetime import datetime
from pandas.tseries.offsets import CustomBusinessDay
# Custom business day starting from April 15, 2021
my_custom_business_day = CustomBusinessDay(name='my_custom_business_day', weekmask='Mon Tue Wed Thu Fri', holidays=[pd.to_datetime('2021-05-01')])
start_date = pd.to_datetime('2021-04-15')
# Add 5 custom business days to start date
end_date = start_date + 5*my_custom_business_day
print(end_date)
Output:
Timestamp('2021-04-22 00:00:00')
In the above code, we have defined a CustomBusinessDay called "my_custom_business_day" which includes weekdays Monday to Friday and excludes the holiday "2021-05-01". We then added 5 my_custom_business_day's to the start date "2021-04-15" to get "2021-04-22".
In this article, we have discussed tseries.offsets.CustomBusinessDay.name
from the offset module. CustomBusinessDay is useful when we want to deal with custom frequency business days. We can define weekdays, holidays, and a name for the CustomBusinessDay object.