Skip to content

Commit 29a9ab4

Browse files
phoflmroeschke
authored andcommitted
Fix pickle roundtrip for new arrow string dtype (pandas-dev#55051)
1 parent 0774ecd commit 29a9ab4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pandas/core/arrays/string_arrow.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,10 @@ def _result_converter(cls, values, na=None):
523523
def __getattribute__(self, item):
524524
# ArrowStringArray and we both inherit from ArrowExtensionArray, which
525525
# creates inheritance problems (Diamond inheritance)
526-
if item in ArrowStringArrayMixin.__dict__ and item != "_pa_array":
526+
if item in ArrowStringArrayMixin.__dict__ and item not in (
527+
"_pa_array",
528+
"__dict__",
529+
):
527530
return partial(getattr(ArrowStringArrayMixin, item), self)
528531
return super().__getattribute__(item)
529532

pandas/tests/arrays/string_/test_string_arrow.py

+3-2
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)