Skip to content

Commit

Permalink
Fix pickle roundtrip for new arrow string dtype
Browse files Browse the repository at this point in the history
  • Loading branch information
phofl committed Sep 7, 2023
1 parent faeedad commit 5306e56
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion pandas/core/arrays/string_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,10 @@ def _result_converter(cls, values, na=None):
def __getattribute__(self, item):
# ArrowStringArray and we both inherit from ArrowExtensionArray, which
# creates inheritance problems (Diamond inheritance)
if item in ArrowStringArrayMixin.__dict__ and item != "_pa_array":
if item in ArrowStringArrayMixin.__dict__ and item not in (
"_pa_array",
"__dict__",
):
return partial(getattr(ArrowStringArrayMixin, item), self)
return super().__getattribute__(item)

Expand Down
5 changes: 3 additions & 2 deletions pandas/tests/arrays/string_/test_string_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,10 @@ def test_setitem_invalid_indexer_raises():


@skip_if_no_pyarrow
def test_pickle_roundtrip():
@pytest.mark.parametrize("dtype", ["string[pyarrow]", "string[pyarrow_numpy]"])
def test_pickle_roundtrip(dtype):
# GH 42600
expected = pd.Series(range(10), dtype="string[pyarrow]")
expected = pd.Series(range(10), dtype=dtype)
expected_sliced = expected.head(2)
full_pickled = pickle.dumps(expected)
sliced_pickled = pickle.dumps(expected_sliced)
Expand Down

0 comments on commit 5306e56

Please sign in to comment.