Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Version 2.3
.. toctree::
:maxdepth: 2

v2.3.1
v2.3.0

Version 2.2
Expand Down
44 changes: 44 additions & 0 deletions doc/source/whatsnew/v2.3.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.. _whatsnew_231:

What's new in 2.3.1 (Month XX, 2025)
---------------------------------------

These are the changes in pandas 2.3.1. See :ref:`release` for a full changelog
including other versions of pandas.

{{ header }}

.. ---------------------------------------------------------------------------
.. _whatsnew_231.enhancements:

Enhancements
~~~~~~~~~~~~
-

.. _whatsnew_231.regressions:

Fixed regressions
~~~~~~~~~~~~~~~~~
-

.. ---------------------------------------------------------------------------
.. _whatsnew_231.bug_fixes:

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

.. ---------------------------------------------------------------------------
.. _whatsnew_231.other:

Other
~~~~~
-

.. ---------------------------------------------------------------------------
.. _whatsnew_231.contributors:

Contributors
~~~~~~~~~~~~

.. contributors:: v2.3.0..v2.3.1
6 changes: 3 additions & 3 deletions pandas/core/arrays/arrow/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1935,9 +1935,9 @@ def _explode(self):
"""
# child class explode method supports only list types; return
# default implementation for non list types.
if not (
pa.types.is_list(self.dtype.pyarrow_dtype)
or pa.types.is_large_list(self.dtype.pyarrow_dtype)
if not hasattr(self.dtype, "pyarrow_dtype") or (
not pa.types.is_list(self.dtype.pyarrow_dtype)
and not pa.types.is_large_list(self.dtype.pyarrow_dtype)
):
return super()._explode()
values = self
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/frame/methods/test_explode.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,11 @@ def test_multi_columns_nan_empty():
index=[0, 0, 1, 2, 3, 3],
)
tm.assert_frame_equal(result, expected)


def test_str_dtype():
# https://github.com/pandas-dev/pandas/pull/61623
df = pd.DataFrame({"a": ["x", "y"]}, dtype="str")
result = df.explode(column="a")
assert result is not df
tm.assert_frame_equal(result, df)
8 changes: 8 additions & 0 deletions pandas/tests/series/methods/test_explode.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,11 @@ def test_explode_pyarrow_non_list_type(ignore_index):
result = ser.explode(ignore_index=ignore_index)
expected = pd.Series([1, 2, 3], dtype="int64[pyarrow]", index=[0, 1, 2])
tm.assert_series_equal(result, expected)


def test_str_dtype():
# https://github.com/pandas-dev/pandas/pull/61623
ser = pd.Series(["x", "y"], dtype="str")
result = ser.explode()
assert result is not ser
tm.assert_series_equal(result, ser)
Loading