Skip to content

Commit b9d8a42

Browse files
committed
update docs
1 parent 94f319e commit b9d8a42

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

doc/source/user_guide/reshaping.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -824,11 +824,11 @@ We can 'explode' this transforming each element of a list-like to a row, by usin
824824
825825
df['values'].explode()
826826
827-
You can easily join this with the original to get an expanded ``DataFrame``.
827+
You can also explode the column in the ``DataFrame``.
828828

829829
.. ipython:: python
830830
831-
df[['keys']].join(df['values'].explode())
831+
df.explode('values')
832832
833833
:meth:`Series.explode` will replace empty lists with ``np.nan`` and preserve scalar entries. The dtype of the resulting ``Series`` is always ``object``.
834834

@@ -850,6 +850,4 @@ Creating a long form DataFrame is now straightforward using explode and chained
850850

851851
.. ipython:: python
852852
853-
exploded = df.var1.str.split(',').explode()
854-
exploded
855-
df[['var2']].join(exploded)
853+
df.assign(var1=df.var1.str.split(',')).explode('var1')

doc/source/whatsnew/v0.25.0.rst

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,9 @@ The repr now looks like this:
187187
Series.explode to split list-like values to rows
188188
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
189189

190-
:class:`Series` has gained the :meth:`Series.explode` method to transform list-likes to individual rows. See :ref:`section on Exploding list-like column <reshaping.explode>` in docs for more information (:issue:`16538`, :issue:`10511`)
190+
:class:`Series` and :class:`DataFrame` have gained the :meth:`DataFrame.explode` methods to transform list-likes to individual rows. See :ref:`section on Exploding list-like column <reshaping.explode>` in docs for more information (:issue:`16538`, :issue:`10511`)
191191

192192

193-
.. ipython:: python
194-
195-
s = pd.Series([[1, 2, 3], np.nan, [], [3, 4]])
196-
s
197-
s.explode()
198-
199193
Here is a typical usecase. You have comma separated string in a column.
200194

201195
.. ipython:: python
@@ -208,9 +202,7 @@ Creating a long form ``DataFrame`` is now straightforward using chained operatio
208202

209203
.. ipython:: python
210204
211-
exploded = df.var1.str.split(',').explode()
212-
exploded
213-
df[['var2']].join(exploded)
205+
df.assign(var1=df.var1.str.split(',')).explode('var1')
214206
215207
.. _whatsnew_0250.enhancements.other:
216208

0 commit comments

Comments
 (0)