From the course: Python for Data Visualization (2019)

Unlock this course with a free trial

Join today to access over 22,500 courses taught by industry experts.

Renaming and deleting columns

Renaming and deleting columns

- [Narrator] When you have a data set, it's often the case where you want to change your column names to make the more legible, more understandable, or more easy to program with. Or sometimes you want to remove unnecessary columns. An advantage of removing unnecessary columns is it can free up RAM on your computer. It's also a good data science practice. There are two popular ways to rename data frame columns. The first is dictionary substitution, which is very useful if you only want to rename a few of your columns. There's also list replacement, which requires a full list of names, and in my experience, this is more error prone. The data set we're going to work with is the car loan data set. And we'll look at the first five rows using the head method. And one reason why I want to rename a column, in this case, the principal paid column, is if I try to use the dot notation wire the data frame and a dot, and the column I'm interested in, this will yield an error.…

Contents