Skip to content

Commit 610c0f4

Browse files
Backport PR #55051 on branch 2.1.x (Fix pickle roundtrip for new arrow string dtype) (#55054)
Backport PR #55051: Fix pickle roundtrip for new arrow string dtype Co-authored-by: Patrick Hoefler <[email protected]>
1 parent 77d29db commit 610c0f4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pandas/core/arrays/string_arrow.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,10 @@ def _result_converter(cls, values, na=None):
466466
def __getattribute__(self, item):
467467
# ArrowStringArray and we both inherit from ArrowExtensionArray, which
468468
# creates inheritance problems (Diamond inheritance)
469-
if item in ArrowStringArrayMixin.__dict__ and item != "_pa_array":
469+
if item in ArrowStringArrayMixin.__dict__ and item not in (
470+
"_pa_array",
471+
"__dict__",
472+
):
470473
return partial(getattr(ArrowStringArrayMixin, item), self)
471474
return super().__getattribute__(item)
472475

pandas/tests/arrays/string_/test_string_arrow.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,10 @@ def test_setitem_invalid_indexer_raises():
241241

242242

243243
@skip_if_no_pyarrow
244-
def test_pickle_roundtrip():
244+
@pytest.mark.parametrize("dtype", ["string[pyarrow]", "string[pyarrow_numpy]"])
245+
def test_pickle_roundtrip(dtype):
245246
# GH 42600
246-
expected = pd.Series(range(10), dtype="string[pyarrow]")
247+
expected = pd.Series(range(10), dtype=dtype)
247248
expected_sliced = expected.head(2)
248249
full_pickled = pickle.dumps(expected)
249250
sliced_pickled = pickle.dumps(expected_sliced)

0 commit comments

Comments
 (0)