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 set_index() - pandas Tutorial
From the course: pandas Essential Training
Using set_index()
- [Narrator] The set index allows us to determine which of the series is going to be the index. We will use the set index with one key parameter, which is the keys. We will look at inplace in particular, in the next Jupyter notebook. Now remember that I said, one of the advantages of Pandas is that you can use labels as an index. So let's set the athlete series as our index. Now, what I'm going to do is I'm going to show you two ways of going about this. So let's look at our original data frame, which is oo.head. And we can see that currently, the index is this first column. And this data frame is indexed by these numbers. Now, if I want to set the athlete as the index, one way of doing this is to use the oo.set index and I specify that I want this data frame indexed by athlete. And you can see, that the athlete is now in bold, and this first column is your index. Now, let's confirm that the athlete is in fact our index. So I'm going to do another head on my original data frame, and…
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.