Tutorials References Exercises Videos Menu
Create Website Get Certified Upgrade

Pandas DataFrame add_suffix() Method

❮ DataFrame Reference


Example

Insert "_data" after each column label:

import pandas as pd

data = {
  "age": [50, 40, 30, 40, 20, 10, 30],
  "qualified": [True, False, False, False, False, True, True]
}
df = pd.DataFrame(data)

newdf = df.add_suffix("_after")
Try it Yourself »

Definition and Usage

The add_suffix() method inserts the specified value at the end of each column label.

To add a value before the column label, use the  add_prefix() method.


Syntax

dataframe.suffix(prefix)

Parameters

Parameter Description
prefix Required. A string to add after the column labels

Return Value

A DataFrame with the result.

This method does not change the original DataFrame.


❮ DataFrame Reference