pandas.DataFrame.add_prefix

pandas 3.1.1 · DataFrame · method

Prepend text to labels on the chosen axis.

Call syntax

DataFrame.add_prefix(prefix, axis=None)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
prefix Required
Positional or keyword
str

Add text before generated labels or test for a beginning substring.

axis Optional
Positional or keyword
Default None
{0 or 'index', 1 or 'columns', None}

Choose which axis the operation acts on. The accepted axis labels depend on the receiver.

Returns

Series or DataFrame