Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ENH: Support for Orthodox Easter #61665

Closed
@w3stling

Description

@w3stling

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

The pandas.tseries.offsets.Easter class currently calculates the date of Western Easter only. However, it does not support the calculation of Orthodox Easter.

This limitation makes it more difficult to work with holidays that are relative to Orthodox Easter, such as Orthodox Good Friday and Orthodox Easter Monday.

Feature Description

With a small and fully backwards-compatible change to the pandas.tseries.offsets.Easter class, support for Orthodox Easter (and Julian Easter) can be added by introducing an optional method parameter to the Easter constructor.

This method parameter specifies the method to use for calculating easter and would then be passed to dateutil.easter, which is used internally by the Easter class.

Usage example:

from dateutil.easter import EASTER_ORTHODOX

OrthodoxGoodFriday = Holiday("Good Friday", month=1, day=1, offset=[Easter(method=EASTER_ORTHODOX), Day(-2)])
OrthodoxEasterMonday = Holiday("Easter Monday", month=1, day=1, offset=[Easter(method=EASTER_ORTHODOX), Day(1)])

This is similar to how the GoodFriday and EasterMonday holidays for Western Easter are implemented in the pandas.tseries.holiday module.

Alternative Solutions

An alternative solution, without modifying the Easter class as suggested, is to use the observance parameter.

def calculate_orthodox_good_friday(dt):
    offset = easter(dt.year, method=EASTER_ORTHODOX) - timedelta(days=2) - dt.date()
    return dt + offset

OrthodoxGoodFriday = Holiday(
    "Good Friday",
    month=1,
    day=1,
    observance=calculate_orthodox_good_friday)

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions