python-holidays icon indicating copy to clipboard operation
python-holidays copied to clipboard

Add Pandas submodule

Open YusufBerki opened this issue 2 years ago • 2 comments

Added 2 functions to convert HolidayBase object into Pandas Series or Pandas DataFrame.

These functions were not added to the HolidayBase class as a method in order not to require Pandas in library installation and use. So only those who want to use these functions will have to install Pandas.

Usage:

>>> import holidays
>>> us = holidays.US(years=[2022])

>>> from holidays.pandas import holidays_to_series
>>> holidays_to_series(us)
2022-01-01                                     New Year's Day
2022-01-17                         Martin Luther King Jr. Day
2022-02-21                              Washington's Birthday
2022-05-30                                       Memorial Day
2022-06-19               Juneteenth National Independence Day
2022-06-20    Juneteenth National Independence Day (Observed)
2022-07-04                                   Independence Day
2022-09-05                                          Labor Day
2022-10-10                                       Columbus Day
2022-11-11                                       Veterans Day
2022-11-24                                       Thanksgiving
2022-12-25                                      Christmas Day
2022-12-26                           Christmas Day (Observed)
Name: holiday, dtype: object

YusufBerki avatar Aug 21 '22 13:08 YusufBerki

Pull Request Test Coverage Report for Build 2898660991

  • 0 of 6 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.06%) to 99.565%

Changes Missing Coverage Covered Lines Changed/Added Lines %
holidays/pandas.py 0 6 0.0%
<!-- Total: 0 6
Totals Coverage Status
Change from base Build 2897604800: -0.06%
Covered Lines: 6427
Relevant Lines: 6445

💛 - Coveralls

coveralls avatar Sep 14 '22 08:09 coveralls

Hi @YusufBerki,

Thank you for the PR and your work towards improving python-holidays.

I have a couple of thoughts regarding the PR itself and its place in the library:

  • first of all I'm not a person who decides the eventual PR acceptance, it's just my own opinion: the code changes are clean and well documented however they don't look very related to the original library purpose.
  • it seems that data transformation takes just a couple of extra lines and can be easily done outside of the library.
  • and last but not least: it's kind of a requirement to have unit test in order to get your PR accepted, so I suggest adding ones if you still want this code to become a part of the python-holidays.

Thank you!

-- Ark

arkid15r avatar Sep 16 '22 16:09 arkid15r

Hi @YusufBerki , sorry, I have to agree with @arkid15r : although well documented, your PR doesn't add so much value, but instead enforces a dependency (even if not strict) to Pandas which, not being really required, at the moment we would rather avoid to add. Therefore, we won't receive it as it is: we could reconsider it in case of more valuable additions.

Thanks all the same, cheers

dr-prodigy avatar Oct 17 '22 21:10 dr-prodigy