Skip to content
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
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,8 @@ ExtensionArray
- Bug in :meth:`.arrays.ArrowExtensionArray.__setitem__` which caused wrong behavior when using an integer array with repeated values as a key (:issue:`58530`)
- Bug in :meth:`api.types.is_datetime64_any_dtype` where a custom :class:`ExtensionDtype` would return ``False`` for array-likes (:issue:`57055`)
- Bug in comparison between object with :class:`ArrowDtype` and incompatible-dtyped (e.g. string vs bool) incorrectly raising instead of returning all-``False`` (for ``==``) or all-``True`` (for ``!=``) (:issue:`59505`)
- Bug in constructing pandas data structures when passing into ``dtype`` a string of the type followed by
``[pyarrow]`` while PyArrow is not installed would raise ``NameError`` rather than ``ImportError`` (:issue:`57928`)
- Bug in various :class:`DataFrame` reductions for pyarrow temporal dtypes returning incorrect dtype when result was null (:issue:`59234`)

Styler
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


base_type = string[:-9] # get rid of "[pyarrow]"
try:
Expand Down
12 changes: 11 additions & 1 deletion pandas/tests/dtypes/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import numpy as np
import pytest

from pandas.compat import HAS_PYARROW
from pandas.compat import (
HAS_PYARROW,
pa_version_under10p1,
)
import pandas.util._test_decorators as td

from pandas.core.dtypes.astype import astype_array
Expand Down Expand Up @@ -835,3 +838,10 @@ def test_pandas_dtype_string_dtypes(string_storage):
with pd.option_context("string_storage", string_storage):
result = pandas_dtype("string")
assert result == pd.StringDtype(string_storage, na_value=pd.NA)


@pytest.mark.skipif(not pa_version_under10p1, reason="pyarrow>=10.0.1 installed")
def test_construct_from_string_without_pyarrow_installed():
# GH 57928
with pytest.raises(ImportError, match="pyarrow>=10.0.1 is required"):
pd.Series([-1.5, 0.2, None], dtype="float32[pyarrow]")
Loading