pythonintermediate
Pandas Business Day Offsets
Compute business-day-adjusted dates using pandas offsets for financial and SLA calculations.
pythonPress ⌘/Ctrl + Shift + C to copy
import pandas as pd
from pandas.tseries.offsets import BDay, BusinessMonthEnd, QuarterEnd
today = pd.Timestamp('2024-03-15')
print('Next bday: ', today + BDay(1))
print('5 bdays later: ', today + BDay(5))
print('Business month end:', today + BusinessMonthEnd())
print('Quarter end: ', today + QuarterEnd())
dates = pd.date_range('2024-01-01', periods=10, freq='B') # Business days
print(dates)Use Cases
- financial calendars
- SLA deadlines
- settlement dates
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
pythonintermediate
Timezone-Aware Timestamps in pandas
Convert naive timestamps to timezone-aware, handle DST transitions, and localise to UTC.
Best for: global event logs
#pandas#datetime
pythonbeginner
Pandas Datetime Component Extraction
Extract year, month, day, hour, day-of-week and other components from a datetime column.
Best for: time-based features
#pandas#datetime
pythonbeginner
Pandas DataFrame Transformations
Common pandas DataFrame transformations including column operations, type casting, and string methods.
Best for: Cleaning raw data files for analysis
#pandas#dataframe
pythonbeginner
Pandas DataFrame Filtering Techniques
Filter DataFrames using boolean masks, query syntax, isin, between, and string matching methods.
Best for: Extracting subsets of data for reporting
#pandas#filtering