Apply the given offset/observance to a DatetimeIndex of dates. Parameters ---------- dates : DatetimeIndex Dates to apply the given offset/observance rule Returns ------- Dates with rules applied
(self, dates: DatetimeIndex)
| 394 | return dates |
| 395 | |
| 396 | def _apply_rule(self, dates: DatetimeIndex) -> DatetimeIndex: |
| 397 | """ |
| 398 | Apply the given offset/observance to a DatetimeIndex of dates. |
| 399 | |
| 400 | Parameters |
| 401 | ---------- |
| 402 | dates : DatetimeIndex |
| 403 | Dates to apply the given offset/observance rule |
| 404 | |
| 405 | Returns |
| 406 | ------- |
| 407 | Dates with rules applied |
| 408 | """ |
| 409 | if dates.empty: |
| 410 | return dates.copy() |
| 411 | |
| 412 | if self.observance is not None: |
| 413 | return dates.map(lambda d: self.observance(d)) |
| 414 | |
| 415 | if self.offset is not None: |
| 416 | if not isinstance(self.offset, list): |
| 417 | offsets = [self.offset] |
| 418 | else: |
| 419 | offsets = self.offset |
| 420 | for offset in offsets: |
| 421 | # if we are adding a non-vectorized value |
| 422 | # ignore the PerformanceWarnings: |
| 423 | with warnings.catch_warnings(): |
| 424 | warnings.simplefilter("ignore", PerformanceWarning) |
| 425 | dates += offset |
| 426 | return dates |
| 427 | |
| 428 | |
| 429 | holiday_calendars: dict[str, type[AbstractHolidayCalendar]] = {} |