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

BUG: fix NameError raised when specifying dtype with string having "[pyarrow]" while PyArrow is not installed #60413

Merged
merged 8 commits into from
Nov 27, 2024

Conversation

yuanx749
Copy link
Contributor

@yuanx749 yuanx749 commented Nov 25, 2024

I thinks this is more like a bug than enhancement, as quoted from the OP:

This conforms to the description in Installation Guide: If the optional dependency is not installed, pandas will raise an ImportError when the method requiring that dependency is called.

@@ -2344,6 +2344,8 @@ def construct_from_string(cls, string: str) -> ArrowDtype:
if string == "string[pyarrow]":
# Ensure Registry.find skips ArrowDtype to use StringDtype instead
raise TypeError("string[pyarrow] should be constructed by StringDtype")
if pa_version_under10p1:
raise ImportError("pyarrow>=10.0.1 is required for ArrowDtype")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These lines follow the error raised in ArrowDtype:

if pa_version_under10p1:
raise ImportError("pyarrow>=10.0.1 is required for ArrowDtype")

@mroeschke mroeschke added the Arrow pyarrow functionality label Nov 25, 2024
@mroeschke mroeschke merged commit 1d809c3 into pandas-dev:main Nov 27, 2024
51 checks passed
@mroeschke mroeschke added this to the 3.0 milestone Nov 27, 2024
@mroeschke
Copy link
Member

Thanks @yuanx749

@yuanx749 yuanx749 deleted the pyarrow-nameerror branch November 28, 2024 00:02
tasfia8 pushed a commit to tasfia8/pandas-tasfia8 that referenced this pull request Nov 28, 2024
…pyarrow]" while PyArrow is not installed (pandas-dev#60413)

* Add test

* Fix

* Add note

* Update pandas/tests/dtypes/test_common.py

Co-authored-by: Matthew Roeschke <[email protected]>

* update

* Fix doc warning

---------

Co-authored-by: Matthew Roeschke <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: Improve error message when specifying dtype="float32[pyarrow]" while PyArrow is not installed
2 participants