You may have a table with long column names that contain suffixes like “Undergraduate_Student”, where the suffix is “_Student”. These long column names can be difficult to work with because typing them is time-consuming. Fortunately, there’s a way to fix this. Below is a dataframe showing graduate and undergraduate students.
shape: (4, 2)
Undergraduate_Student
Graduate_Student
str
str
"Lauren"
"Gabrielle"
"Larry"
"Penny"
"Chanda"
"Chisenga"
"Katis"
"Titus"
Remove suffix in column names
You can remove the suffix “_Student” from the column names by using the expression name.map. This allows you to change column names without manually typing both the original names and their replacements, such as: