Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

importing this package alters the behavior of pandas #301

Open
erikhansenwong opened this issue Oct 27, 2023 · 1 comment
Open

importing this package alters the behavior of pandas #301

erikhansenwong opened this issue Oct 27, 2023 · 1 comment

Comments

@erikhansenwong
Copy link

This package modifies the behavior of core pandas features here in pandas_market_calendars/calendars/nyse.py

# Overwrite the default holiday calendar start_date of 1/1/70 
AbstractHolidayCalendar.start_date = '1885-01-01'

There are several other ways this can be handled without changing the behavior of classes in a third party library.

Here is an example of a test which should pass, but which currently fails with v4.3.1

def test_custom_business_day():
    import pandas as pd
    from pandas.tseries.holiday import MO, AbstractHolidayCalendar, Holiday
    from pandas.tseries.offsets import CustomBusinessDay

    USMemorialDay = Holiday(
        "Memorial Day", month=5, day=31, offset=pd.DateOffset(weekday=MO(-1))
    )

    class ExampleCalendar(AbstractHolidayCalendar):
        rules = [USMemorialDay]

    bday1 = CustomBusinessDay(calendar=ExampleCalendar())
    bday2 = CustomBusinessDay(calendar=ExampleCalendar())

    # this assertion passes
    assert bday1 == bday2

    # but then we import pandas_market_calendars and try the same thing ...
    import pandas_market_calendars

    bday3 = CustomBusinessDay(calendar=ExampleCalendar())

    # and now this assertion fails
    assert bday1 == bday3
@rsheftel
Copy link
Owner

Do you have specific suggestion on how to modify the code? Can you submit a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants