w3resource

Pandas Series: add_prefix() function

Prefix labels with string prefix in Pandas series

The add_prefix() function is used to prefix labels with string prefix.

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

Syntax:

Series.add_prefix(self, prefix)
Pandas Series add_prefix image

Parameters:

Name Description Type/Default Value Required / Optional
prefix The string to add before each label. str Required

Returns: Series or DataFrame
New Series or DataFrame with updated labels.

Example:


Download the above Notebook from here.



Inviting useful, relevant, well-written and unique guest posts