Skip to content

Commit 6294d84

Browse files
authored
DOC: Improve reshaping.rst (#45612)
1 parent 57d7768 commit 6294d84

File tree

8 files changed

+97
-90
lines changed

8 files changed

+97
-90
lines changed

doc/source/user_guide/reshaping.rst

+61-90
Large diffs are not rendered by default.

pandas/core/algorithms.py

+4
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,10 @@ def factorize(
631631
cut : Discretize continuous-valued array.
632632
unique : Find the unique value in an array.
633633
634+
Notes
635+
-----
636+
Reference :ref:`the user guide <reshaping.factorize>` for more examples.
637+
634638
Examples
635639
--------
636640
These examples all show factorize as a top-level method like

pandas/core/frame.py

+14
Original file line numberDiff line numberDiff line change
@@ -7792,6 +7792,8 @@ def groupby(
77927792
For finer-tuned control, see hierarchical indexing documentation along
77937793
with the related stack/unstack methods.
77947794
7795+
Reference :ref:`the user guide <reshaping.pivot>` for more examples.
7796+
77957797
Examples
77967798
--------
77977799
>>> df = pd.DataFrame({'foo': ['one', 'one', 'one', 'two', 'two',
@@ -7950,6 +7952,10 @@ def pivot(self, index=None, columns=None, values=None) -> DataFrame:
79507952
wide_to_long : Wide panel to long format. Less flexible but more
79517953
user-friendly than melt.
79527954
7955+
Notes
7956+
-----
7957+
Reference :ref:`the user guide <reshaping.pivot>` for more examples.
7958+
79537959
Examples
79547960
--------
79557961
>>> df = pd.DataFrame({"A": ["foo", "foo", "foo", "foo", "foo",
@@ -8106,6 +8112,8 @@ def stack(self, level: Level = -1, dropna: bool = True):
81068112
vertically on top of each other (in the index of the
81078113
dataframe).
81088114
8115+
Reference :ref:`the user guide <reshaping.stacking>` for more examples.
8116+
81098117
Examples
81108118
--------
81118119
**Single level columns**
@@ -8285,6 +8293,8 @@ def explode(
82858293
result in a np.nan for that row. In addition, the ordering of rows in the
82868294
output will be non-deterministic when exploding sets.
82878295
8296+
Reference :ref:`the user guide <reshaping.explode>` for more examples.
8297+
82888298
Examples
82898299
--------
82908300
>>> df = pd.DataFrame({'A': [[0, 1, 2], 'foo', [], [3, 4]],
@@ -8384,6 +8394,10 @@ def unstack(self, level: Level = -1, fill_value=None):
83848394
DataFrame.stack : Pivot a level of the column labels (inverse operation
83858395
from `unstack`).
83868396
8397+
Notes
8398+
-----
8399+
Reference :ref:`the user guide <reshaping.stacking>` for more examples.
8400+
83878401
Examples
83888402
--------
83898403
>>> index = pd.MultiIndex.from_tuples([('one', 'a'), ('one', 'b'),

pandas/core/reshape/pivot.py

+2
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,8 @@ def crosstab(
589589
In the event that there aren't overlapping indexes an empty DataFrame will
590590
be returned.
591591
592+
Reference :ref:`the user guide <reshaping.crosstabulations>` for more examples.
593+
592594
Examples
593595
--------
594596
>>> a = np.array(["foo", "foo", "foo", "foo", "bar", "bar",

pandas/core/reshape/reshape.py

+4
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,10 @@ def get_dummies(
857857
--------
858858
Series.str.get_dummies : Convert Series to dummy codes.
859859
860+
Notes
861+
-----
862+
Reference :ref:`the user guide <reshaping.dummies>` for more examples.
863+
860864
Examples
861865
--------
862866
>>> s = pd.Series(list('abca'))

pandas/core/reshape/tile.py

+2
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ def cut(
145145
Any NA values will be NA in the result. Out of bounds values will be NA in
146146
the resulting Series or Categorical object.
147147
148+
Reference :ref:`the user guide <reshaping.tile.cut>` for more examples.
149+
148150
Examples
149151
--------
150152
Discretize into three equal-sized bins.

pandas/core/series.py

+6
Original file line numberDiff line numberDiff line change
@@ -4083,6 +4083,8 @@ def explode(self, ignore_index: bool = False) -> Series:
40834083
result in a np.nan for that row. In addition, the ordering of elements in
40844084
the output will be non-deterministic when exploding sets.
40854085
4086+
Reference :ref:`the user guide <reshaping.explode>` for more examples.
4087+
40864088
Examples
40874089
--------
40884090
>>> s = pd.Series([[1, 2, 3], 'foo', [], [3, 4]])
@@ -4132,6 +4134,10 @@ def unstack(self, level=-1, fill_value=None) -> DataFrame:
41324134
DataFrame
41334135
Unstacked Series.
41344136
4137+
Notes
4138+
-----
4139+
Reference :ref:`the user guide <reshaping.stacking>` for more examples.
4140+
41354141
Examples
41364142
--------
41374143
>>> s = pd.Series([1, 2, 3, 4],

pandas/core/shared_docs.py

+4
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@
195195
DataFrame.explode : Explode a DataFrame from list-like
196196
columns to long format.
197197
198+
Notes
199+
-----
200+
Reference :ref:`the user guide <reshaping.melt>` for more examples.
201+
198202
Examples
199203
--------
200204
>>> df = pd.DataFrame({'A': {0: 'a', 1: 'b', 2: 'c'},

0 commit comments

Comments
 (0)