str | String to be suffixed to column names . |
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
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
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.