From the course: pandas Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Using reset_index() - pandas Tutorial
From the course: pandas Essential Training
Using reset_index()
- [Narrator] Now, not surprisingly, the opposite of setting an index is to reset the index. And what we're doing here is we're returning a DataFrame to its default, integer-based index. Let's head over to our Jupyter notebook for an example. Now we know that ath is a data frame that is indexed by athlete, because we did this in the previous video. So let's reset the ath data frame, so that it is indexed by the integers. So ath.reset_index, and SHIFT and TAB to look at the options, and we see that we run into the same problem that we did with set_index where we need to specify that the inplace is true, if we want to do it to the ath data frame, or we can specify that inplace equals false, and then we need to set this data frame to another data frame. So let's say, inplace equals true. And we do an ath.head and here we expect the index to be back to the integer-based indices for our data frame. In the real world, you can often use the reset index, especially when you're trying to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.