Skip to content

Commit 74111f6

Browse files
committed
DOC: Add custom index to example in pandas.DataFrame.append pandas-dev#41407
Change index to [0, 2] to stress that ignore_index=True resets the index of both dataframes
1 parent b472080 commit 74111f6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pandas/core/frame.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -8811,18 +8811,18 @@ def append(
88118811
88128812
Examples
88138813
--------
8814-
>>> df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'))
8814+
>>> df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'), index=[0,2])
88158815
>>> df
88168816
A B
88178817
0 1 2
8818-
1 3 4
8819-
>>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=list('AB'))
8818+
2 3 4
8819+
>>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=list('AB'), index=[0,2])
88208820
>>> df.append(df2)
88218821
A B
88228822
0 1 2
8823-
1 3 4
8823+
2 3 4
88248824
0 5 6
8825-
1 7 8
8825+
2 7 8
88268826
88278827
With `ignore_index` set to True:
88288828

0 commit comments

Comments
 (0)