@@ -2951,7 +2951,8 @@ def add_prefix(self, prefix):
2951
2951
2952
2952
See Also
2953
2953
--------
2954
- Series.add_suffix: Suffix labels with string `suffix`.
2954
+ Series.add_suffix: Suffix row labels with string `suffix`.
2955
+ DataFrame.add_suffix: Suffix column labels with string `suffix`.
2955
2956
2956
2957
Examples
2957
2958
--------
@@ -2990,15 +2991,57 @@ def add_prefix(self, prefix):
2990
2991
2991
2992
def add_suffix (self , suffix ):
2992
2993
"""
2993
- Concatenate suffix string with panel items names.
2994
+ Suffix labels with string `suffix`.
2995
+
2996
+ For Series, the row labels are suffixed.
2997
+ For DataFrame, the column labels are suffixed.
2994
2998
2995
2999
Parameters
2996
3000
----------
2997
- suffix : string
3001
+ suffix : str
3002
+ The string to add after each label.
2998
3003
2999
3004
Returns
3000
3005
-------
3001
- with_suffix : type of caller
3006
+ Series or DataFrame
3007
+ New Series or DataFrame with updated labels.
3008
+
3009
+ See Also
3010
+ --------
3011
+ Series.add_prefix: Prefix row labels with string `prefix`.
3012
+ DataFrame.add_prefix: Prefix column labels with string `prefix`.
3013
+
3014
+ Examples
3015
+ --------
3016
+ >>> s = pd.Series([1, 2, 3, 4])
3017
+ >>> s
3018
+ 0 1
3019
+ 1 2
3020
+ 2 3
3021
+ 3 4
3022
+ dtype: int64
3023
+
3024
+ >>> s.add_suffix('_item')
3025
+ 0_item 1
3026
+ 1_item 2
3027
+ 2_item 3
3028
+ 3_item 4
3029
+ dtype: int64
3030
+
3031
+ >>> df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [3, 4, 5, 6]})
3032
+ >>> df
3033
+ A B
3034
+ 0 1 3
3035
+ 1 2 4
3036
+ 2 3 5
3037
+ 3 4 6
3038
+
3039
+ >>> df.add_suffix('_col')
3040
+ A_col B_col
3041
+ 0 1 3
3042
+ 1 2 4
3043
+ 2 3 5
3044
+ 3 4 6
3002
3045
"""
3003
3046
new_data = self ._data .add_suffix (suffix )
3004
3047
return self ._constructor (new_data ).__finalize__ (self )
0 commit comments