Legacy – Renaming Columns Workout
- 01:44
Workout demonstrating how to rename the columns of the dataset in the Pandas library.
Transcript
We did in the first place important massive data set into Python. And then we've taken a subset of the data set. But we did observe that the subset data set does not have a proper column naming. So how do we change the names of a column of a data set. So let us first run this code, which will essentially load the data set load the subset of it. Now, in order to take a subset of the data and then change the names, it's really simple. We select the data, the shorter version, in this case, and we say columns equals , appropriate names, and it this equals square brackets, and we write the appropriate names. So we said name of the second one is the first day, second day, and so on the fifth day. Now we try to run this code. Perfect, there aren't any errors returned. Let us now print the shorter version of the dataset after renaming the columns. If we look at it, we can see that the naming has changed into name first day, second day, third day for the fifth day, which is perfect. Rather than opening the Excel file, which takes longer to open we could straightaway change the names of the columns like we desire