@@ -2726,8 +2726,8 @@ def duplicated(self, subset=None, take_last=False):
2726
2726
Only consider certain columns for identifying duplicates, by
2727
2727
default use all of the columns
2728
2728
take_last : boolean, default False
2729
- For a set of distinct duplicate rows, flag all but the last row as
2730
- duplicated. Default is for all but the first row to be flagged
2729
+ For a set of distinct duplicate rows, flag all but the last row as
2730
+ duplicated. Default is for all but the first row to be flagged
2731
2731
cols : kwargs only argument of subset [deprecated]
2732
2732
2733
2733
Returns
@@ -3770,35 +3770,65 @@ def infer(x):
3770
3770
3771
3771
def append (self , other , ignore_index = False , verify_integrity = False ):
3772
3772
"""
3773
- Append columns of other to end of this frame's columns and index,
3774
- returning a new object. Columns not in this frame are added as new
3775
- columns.
3773
+ Append rows of `other` to the end of this frame, returning a new
3774
+ object. Columns not in this frame are added as new columns.
3776
3775
3777
3776
Parameters
3778
3777
----------
3779
- other : DataFrame or list of Series/dict-like objects
3778
+ other : DataFrame or Series/dict-like object, or list of these
3779
+ The data to append.
3780
3780
ignore_index : boolean, default False
3781
- If True do not use the index labels. Useful for gluing together
3782
- record arrays
3781
+ If True, do not use the index labels.
3783
3782
verify_integrity : boolean, default False
3784
- If True, raise ValueError on creating index with duplicates
3783
+ If True, raise ValueError on creating index with duplicates.
3784
+
3785
+ Returns
3786
+ -------
3787
+ appended : DataFrame
3785
3788
3786
3789
Notes
3787
3790
-----
3788
- If a list of dict is passed and the keys are all contained in the
3791
+ If a list of dict/series is passed and the keys are all contained in the
3789
3792
DataFrame's index, the order of the columns in the resulting DataFrame
3790
- will be unchanged
3793
+ will be unchanged.
3794
+
3795
+ See also
3796
+ --------
3797
+ pandas.concat : General function to concatenate DataFrame, Series
3798
+ or Panel objects
3799
+
3800
+ Examples
3801
+ --------
3802
+
3803
+ >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'))
3804
+ >>> df
3805
+ A B
3806
+ 0 1 2
3807
+ 1 3 4
3808
+ >>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=list('AB'))
3809
+ >>> df.append(df2)
3810
+ A B
3811
+ 0 1 2
3812
+ 1 3 4
3813
+ 0 5 6
3814
+ 1 7 8
3815
+
3816
+ With `ignore_index` set to True:
3817
+
3818
+ >>> df.append(df2, ignore_index=True)
3819
+ A B
3820
+ 0 1 2
3821
+ 1 3 4
3822
+ 2 5 6
3823
+ 3 7 8
3791
3824
3792
- Returns
3793
- -------
3794
- appended : DataFrame
3795
3825
"""
3796
3826
if isinstance (other , (Series , dict )):
3797
3827
if isinstance (other , dict ):
3798
3828
other = Series (other )
3799
3829
if other .name is None and not ignore_index :
3800
- raise TypeError ('Can only append a Series if '
3801
- 'ignore_index=True ' )
3830
+ raise TypeError ('Can only append a Series if ignore_index=True '
3831
+ ' or if the Series has a name ' )
3802
3832
3803
3833
index = None if other .name is None else [other .name ]
3804
3834
combined_columns = self .columns .tolist () + self .columns .union (other .index ).difference (self .columns ).tolist ()
0 commit comments