Skip to content

Commit 56714c9

Browse files
post merge fixup
1 parent 3ad0638 commit 56714c9

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

pandas/core/arrays/string_.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
Scalar,
2020
type_t,
2121
)
22+
from pandas.compat import pa_version_under1p0
2223
from pandas.compat.numpy import function as nv
2324

2425
from pandas.core.dtypes.base import (
@@ -94,6 +95,11 @@ def __init__(self, storage=None):
9495
raise ValueError(
9596
f"Storage must be 'python' or 'pyarrow'. Got {storage} instead."
9697
)
98+
if storage == "pyarrow" and pa_version_under1p0:
99+
raise ImportError(
100+
"pyarrow>=1.0.0 is required for PyArrow backed StringArray."
101+
)
102+
97103
self.storage = storage
98104

99105
@property

pandas/tests/arrays/string_/test_string_arrow.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@
1111
StringArray,
1212
StringDtype,
1313
)
14-
from pandas.core.arrays.string_arrow import (
15-
ArrowStringArray,
14+
from pandas.core.arrays.string_arrow import ArrowStringArray
15+
16+
skip_if_no_pyarrow = pytest.mark.skipif(
17+
pa_version_under1p0,
18+
reason="pyarrow>=1.0.0 is required for PyArrow backed StringArray",
1619
)
1720

1821

22+
@skip_if_no_pyarrow
1923
def test_eq_all_na():
2024
a = pd.array([pd.NA, pd.NA], dtype=StringDtype("pyarrow"))
2125
result = a == a
@@ -41,10 +45,7 @@ def test_config_bad_storage_raises():
4145
pd.options.mode.string_storage = "foo"
4246

4347

44-
@pytest.mark.skipif(
45-
pa_version_under1p0,
46-
reason="pyarrow>=1.0.0 is required for PyArrow backed StringArray",
47-
)
48+
@skip_if_no_pyarrow
4849
@pytest.mark.parametrize("chunked", [True, False])
4950
@pytest.mark.parametrize("array", ["numpy", "pyarrow"])
5051
def test_constructor_not_string_type_raises(array, chunked):
@@ -67,6 +68,7 @@ def test_constructor_not_string_type_raises(array, chunked):
6768
ArrowStringArray(arr)
6869

6970

71+
@skip_if_no_pyarrow
7072
def test_from_sequence_wrong_dtype_raises():
7173
with pd.option_context("string_storage", "python"):
7274
ArrowStringArray._from_sequence(["a", None, "c"], dtype="string")

0 commit comments

Comments
 (0)