Skip to content

Commit bb5bfa6

Browse files
authored
DOC: Improve examples of df.append to better show the ignore_index param (#41444)
1 parent f7253ba commit bb5bfa6

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

pandas/core/frame.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -8793,6 +8793,7 @@ def append(
87938793
Returns
87948794
-------
87958795
DataFrame
8796+
A new DataFrame consisting of the rows of caller and the rows of `other`.
87968797
87978798
See Also
87988799
--------
@@ -8811,18 +8812,18 @@ def append(
88118812
88128813
Examples
88138814
--------
8814-
>>> df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'))
8815+
>>> df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'), index=['x', 'y'])
88158816
>>> df
88168817
A B
8817-
0 1 2
8818-
1 3 4
8819-
>>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=list('AB'))
8818+
x 1 2
8819+
y 3 4
8820+
>>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=list('AB'), index=['x', 'y'])
88208821
>>> df.append(df2)
88218822
A B
8822-
0 1 2
8823-
1 3 4
8824-
0 5 6
8825-
1 7 8
8823+
x 1 2
8824+
y 3 4
8825+
x 5 6
8826+
y 7 8
88268827
88278828
With `ignore_index` set to True:
88288829

0 commit comments

Comments
 (0)