Skip to content

Commit

Permalink
Backport PR #55051 on branch 2.1.x (Fix pickle roundtrip for new arro…
Browse files Browse the repository at this point in the history
…w string dtype) (#55054)

Backport PR #55051: Fix pickle roundtrip for new arrow string dtype

Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
  • Loading branch information
meeseeksmachine and phofl committed Sep 7, 2023
1 parent 77d29db commit 610c0f4
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 @@ -466,7 +466,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 610c0f4

Please sign in to comment.