add_suffix() : suffix columns

DataFrame.add_suffix('str')
strString to be suffixed to column names .

Using DataFrame

We are trying to change the column NAME to name1
import pandas as pd 
my_dict={'NAME':['Ravi','Raju','Alex','Ron','King','Jack'],
         'ID':[1,2,3,4,5,6],'MATH':[30,40,50,60,70,80],
         'ENGLISH':[20,30,40,50,60,70]}
my_data = pd.DataFrame(data=my_dict)
my_data=my_data.add_suffix('_Col')
print(my_data)
Output
  NAME_Col  ID_Col  MATH_Col  ENGLISH_Col
0     Ravi       1        30           20
1     Raju       2        40           30
2     Alex       3        50           40
3      Ron       4        60           50
4     King       5        70           60
5     Jack       6        80           70

Using series

my_s=pd.Series([1,5,7,9,10])
my_s=my_s.add_suffix('_Ser')
print(my_s)
Output
0_Ser     1
1_Ser     5
2_Ser     7
3_Ser     9
4_Ser    10
dtype: int64


Pandas columns() rename() add_prefix()
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com







Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer