MCPcopy
hub / github.com/pandas-dev/pandas / add_suffix

Method add_suffix

pandas/core/generic.py:4812–4880  ·  view source on GitHub ↗

Suffix labels with string `suffix`. For Series, the row labels are suffixed. For DataFrame, the column labels are suffixed. Parameters ---------- suffix : str The string to add after each label. axis : {0 or 'index', 1 or 'column

(self, suffix: str, axis: Axis | None = None)

Source from the content-addressed store, hash-verified

4810
4811 @final
4812 def add_suffix(self, suffix: str, axis: Axis | None = None) -> Self:
4813 """
4814 Suffix labels with string `suffix`.
4815
4816 For Series, the row labels are suffixed.
4817 For DataFrame, the column labels are suffixed.
4818
4819 Parameters
4820 ----------
4821 suffix : str
4822 The string to add after each label.
4823 axis : {0 or 'index', 1 or 'columns', None}, default None
4824 Axis to add suffix on
4825
4826 .. versionadded:: 2.0.0
4827
4828 Returns
4829 -------
4830 Series or DataFrame
4831 New Series or DataFrame with updated labels.
4832
4833 See Also
4834 --------
4835 Series.add_prefix: Prefix row labels with string `prefix`.
4836 DataFrame.add_prefix: Prefix column labels with string `prefix`.
4837
4838 Examples
4839 --------
4840 >>> s = pd.Series([1, 2, 3, 4])
4841 >>> s
4842 0 1
4843 1 2
4844 2 3
4845 3 4
4846 dtype: int64
4847
4848 >>> s.add_suffix("_item")
4849 0_item 1
4850 1_item 2
4851 2_item 3
4852 3_item 4
4853 dtype: int64
4854
4855 >>> df = pd.DataFrame({"A": [1, 2, 3, 4], "B": [3, 4, 5, 6]})
4856 >>> df
4857 A B
4858 0 1 3
4859 1 2 4
4860 2 3 5
4861 3 4 6
4862
4863 >>> df.add_suffix("_col")
4864 A_col B_col
4865 0 1 3
4866 1 2 4
4867 2 3 5
4868 3 4 6
4869 """

Callers 10

shiftMethod · 0.80
shiftMethod · 0.80
test_add_prefix_suffixFunction · 0.80
test_join_overlapFunction · 0.80
test_add_prefix_suffixFunction · 0.80
test_add_suffixFunction · 0.80

Calls 2

_get_axis_nameMethod · 0.95
_renameMethod · 0.95

Tested by 8

test_add_prefix_suffixFunction · 0.64
test_join_overlapFunction · 0.64
test_add_prefix_suffixFunction · 0.64
test_add_suffixFunction · 0.64