Tutorials References Exercises Sign Up Menu
Create Website Get Certified Pro

Pandas DataFrame add_suffix() Method

❮ DataFrame Reference


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.




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