Skip to main content

Pandas Series: add_suffix() function

In pandas add suffix can be used for both series and dataframe. It is used to suffix labels with string suffix. In series rows, labels are suffixed. In DataFrame columns, labels are suffixed.

Syntax

DataFrame.add_suffix(suffix)

Parameters:

suffix: The string to which we can add after each label.

Returns:

It may be a series or dataframe with updated labels.

Example

import pandas as pd
df_0= pd.DataFrame({'A': [1, 2, 3, 4], 'B': [5, 6, 7, 8]})
df_0

Output

  A B
0 1 5
1 2 6
2 3 7
3 4 8
df_0.add_suffix('_a')

Output

  A_a B_a
0 1 5
1 2 6
2 3 7
3 4 8
Submitted by devanshi.srivastava on November 16, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.