Skip to content

Commit 5468c52

Browse files
authored
Merge branch 'main' into fix/#61636
2 parents fa31d07 + 09f7cc0 commit 5468c52

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

doc/source/development/community.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ people who are hesitant to bring up their questions or ideas on a large public
114114
mailing list or GitHub.
115115

116116
If this sounds like the right place for you, you are welcome to join using
117-
`this link <https://join.slack.com/t/pandas-dev-community/shared_invite/zt-2blg6u9k3-K6_XvMRDZWeH7Id274UeIg>`_!
117+
`this link <https://join.slack.com/t/pandas-dev-community/shared_invite/zt-3813u5fme-hmp5izpbeFl9G8~smrkE~A>`_!
118118
Please remember to follow our `Code of Conduct <https://pandas.pydata.org/community/coc.html>`_,
119119
and be aware that our admins are monitoring for irrelevant messages and will remove folks who use
120120
our

doc/source/whatsnew/v2.3.1.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Fixed regressions
2626

2727
Bug fixes
2828
~~~~~~~~~
29-
-
29+
- Fixed bug in :meth:`DataFrame.explode` and :meth:`Series.explode` where methods would fail with ``dtype="str"`` (:issue:`61623`)
3030

3131
.. ---------------------------------------------------------------------------
3232
.. _whatsnew_231.other:

pandas/core/arrays/arrow/array.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,9 +1950,9 @@ def _explode(self):
19501950
"""
19511951
# child class explode method supports only list types; return
19521952
# default implementation for non list types.
1953-
if not (
1954-
pa.types.is_list(self.dtype.pyarrow_dtype)
1955-
or pa.types.is_large_list(self.dtype.pyarrow_dtype)
1953+
if not hasattr(self.dtype, "pyarrow_dtype") or (
1954+
not pa.types.is_list(self.dtype.pyarrow_dtype)
1955+
and not pa.types.is_large_list(self.dtype.pyarrow_dtype)
19561956
):
19571957
return super()._explode()
19581958
values = self

pandas/tests/frame/methods/test_explode.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,11 @@ def test_multi_columns_nan_empty():
297297
index=[0, 0, 1, 2, 3, 3],
298298
)
299299
tm.assert_frame_equal(result, expected)
300+
301+
302+
def test_str_dtype():
303+
# https://github.com/pandas-dev/pandas/pull/61623
304+
df = pd.DataFrame({"a": ["x", "y"]}, dtype="str")
305+
result = df.explode(column="a")
306+
assert result is not df
307+
tm.assert_frame_equal(result, df)

pandas/tests/series/methods/test_explode.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,11 @@ def test_explode_pyarrow_non_list_type(ignore_index):
175175
result = ser.explode(ignore_index=ignore_index)
176176
expected = pd.Series([1, 2, 3], dtype="int64[pyarrow]", index=[0, 1, 2])
177177
tm.assert_series_equal(result, expected)
178+
179+
180+
def test_str_dtype():
181+
# https://github.com/pandas-dev/pandas/pull/61623
182+
ser = pd.Series(["x", "y"], dtype="str")
183+
result = ser.explode()
184+
assert result is not ser
185+
tm.assert_series_equal(result, ser)

0 commit comments

Comments
 (0)