Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.DataFrame.add_suffix#

DataFrame.add_suffix(suffix,axis=None)[source]#

Suffix labels with stringsuffix.

For Series, the row labels are suffixed.For DataFrame, the column labels are suffixed.

Parameters:
suffixstr

The string to add after each label.

axis{0 or ‘index’, 1 or ‘columns’, None}, default None

Axis to add suffix on

Added in version 2.0.0.

Returns:
Series or DataFrame

New Series or DataFrame with updated labels.

See also

Series.add_prefix

Prefix row labels with stringprefix.

DataFrame.add_prefix

Prefix column labels with stringprefix.

Examples

>>>s=pd.Series([1,2,3,4])>>>s0    11    22    33    4dtype: int64
>>>s.add_suffix('_item')0_item    11_item    22_item    33_item    4dtype: int64
>>>df=pd.DataFrame({'A':[1,2,3,4],'B':[3,4,5,6]})>>>df   A  B0  1  31  2  42  3  53  4  6
>>>df.add_suffix('_col')     A_col  B_col0       1       31       2       42       3       53       4       6

[8]ページ先頭

©2009-2025 Movatter.jp