pandas.DataFrame.add_prefix
-
DataFrame.add_prefix(prefix)[source] -
Префикс меток строкой
prefix.Для Series, метки строк добавляются префикс. Для DataFrame, добавляется префикс к меткам столбцов.
Параметры: prefix : str
Строка, добавляемая перед каждой меткой.
Возвращает: Series или DataFrame
Новая Series или DataFrame с обновлёнными метками.
См. также
-
Series.add_suffix - Добавление суффикса к меткам строк строкой
suffix. -
DataFrame.add_suffix - Добавление суффикса к меткам столбцов строкой
suffix.
Примеры
>>> s = pd.Series([1, 2, 3, 4]) >>> s 0 1 1 2 2 3 3 4 dtype: int64
>>> s.add_prefix('item_') item_0 1 item_1 2 item_2 3 item_3 4 dtype: int64>>> df.add_prefix('col_') col_A col_B 0 1 3 1 2 4 2 3 5 3 4 6 -
© 2008–2012, 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/0.23.4/generated/pandas.DataFrame.add_prefix.html