Skip to content

ENH: Add tzdata to hard dependencies #61308

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

Merged
merged 5 commits into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Other enhancements
- :meth:`pandas.concat` will raise a ``ValueError`` when ``ignore_index=True`` and ``keys`` is not ``None`` (:issue:`59274`)
- :py:class:`frozenset` elements in pandas objects are now natively printed (:issue:`60690`)
- Add ``"delete_rows"`` option to ``if_exists`` argument in :meth:`DataFrame.to_sql` deleting all records of the table before inserting data (:issue:`37210`).
- Added ``tzdata`` to the ``_hard_dependencies`` (:issue:`61273`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_hard dependencies is the internal name of the variable. I think tzdata is already required according to our docs, I guess we may want to have a note for a bug where tzdata being installed wasn't checked? @rhshadrach @mroeschke

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. As only user facing-changes go in the whatsnew, I'd be fine with no note here at all. tzdata was being checked and would certainly raise an import error upon import of pandas, adding it to _hard_dependencies makes the message a bit more clear. If we do go with a note, I'd suggest it stay in other enhancements but be something like

Improved error message when importing pandas and ``tzdata`` is not installed (:issue:`61273`)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@datapythonista @rhshadrach Thanks for your suggestions. I have removed the description about the tzdata dependency from the whatsnew (1955b05).

- Added half-year offset classes :class:`HalfYearBegin`, :class:`HalfYearEnd`, :class:`BHalfYearBegin` and :class:`BHalfYearEnd` (:issue:`60928`)
- Errors occurring during SQL I/O will now throw a generic :class:`.DatabaseError` instead of the raw Exception type from the underlying driver manager library (:issue:`60748`)
- Implemented :meth:`Series.str.isascii` and :meth:`Series.str.isascii` (:issue:`59091`)
Expand Down
2 changes: 1 addition & 1 deletion pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__docformat__ = "restructuredtext"

# Let users know if they're missing any of our hard dependencies
_hard_dependencies = ("numpy", "dateutil")
_hard_dependencies = ("numpy", "dateutil", "tzdata")

for _dependency in _hard_dependencies:
try:
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/test_downstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ def test_yaml_dump(df):
tm.assert_frame_equal(df, loaded2)


@pytest.mark.parametrize("dependency", ["numpy", "dateutil"])
@pytest.mark.parametrize("dependency", ["numpy", "dateutil", "tzdata"])
def test_missing_required_dependency(monkeypatch, dependency):
# GH#61030
# GH#61030, GH61273
original_import = __import__
mock_error = ImportError(f"Mock error for {dependency}")

Expand Down
Loading