pandas.Series.add_suffix
- Series.add_suffix(suffix, axis=None)[source]
-
Добавляет постфикс к меткам с помощью строки suffix.
Для Series добавляется постфикс к меткам строк. Для DataFrame добавляется постфикс к меткам столбцов.
- Параметры:
-
- suffix:str
-
Строка, добавляемая после каждой метки.
- axis:{0 или ‘index’, 1 или ‘columns’, None}, по умолчанию None
-
Ось, к которой добавляется постфикс
Введено в версии 2.0.0.
- Возвращает:
-
- Series или DataFrame
-
Новый Series или DataFrame с обновлёнными метками.
См. также
Series.add_prefix-
Добавляет префикс к меткам строк с помощью строки prefix.
DataFrame.add_prefix-
Добавляет префикс к меткам столбцов с помощью строки prefix.
Примеры
>>> s = pd.Series([1, 2, 3, 4]) >>> s 0 1 1 2 2 3 3 4 dtype: int64
>>> s.add_suffix('_item') 0_item 1 1_item 2 2_item 3 3_item 4 dtype: int64>>> df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [3, 4, 5, 6]}) >>> df A B 0 1 3 1 2 4 2 3 5 3 4 6>>> df.add_suffix('_col') A_col B_col 0 1 3 1 2 4 2 3 5 3 4 6
© 2008–2022, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/2.2.2/reference/api/pandas.Series.add_suffix.html