pandas.DataFrame.add_suffix() function with example program in python

Spread the love

pandas.DataFrame.add_suffix() : This function Suffix labels with string suffix.

Syntax: DataFrame.add_suffix(suffix)

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

suffix : str
The string to add after each label.

Series or DataFrame
New Series or DataFrame with updated labels.

import pandas as pd df = pd.DataFrame({'a': [1, 2, 2], 'b': [30, 40, 50]}) print(df.add_suffix('test'))


   atest  btest
0      1     30
1      2     40
2      2     50



Leave a Reply

Your email address will not be published. Required fields are marked *