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 iloc[] - pandas Tutorial
From the course: pandas Essential Training
Using iloc[]
- [Instructor] Here with Iloc, we're doing selection by integer index. Iloc is primarily integer position based. One of the advantages of Iloc is that it allows for the traditional Pythonic slicing. Let's take a look at a couple of examples in the jupyter notebook. Let's review our data frame again. If I want to see the 1,700th entry, or the index entry, I would type oo.iloc, and remember it's square brackets, 1700. I can see that this corresponds to the athlete, Pierre Rabot. What I can also do with Iloc, is to use a list. So, oo. for my data frame, iloc, and then a list of integers. For example, I might want the integer index 1542, 2390, 6000, and 15000. This will return the rows corresponding to these index. I mentioned earlier that Iloc allows for the traditional Pythonic slicing, so, for example, if I do an oo.head, and look at the first five entries in my data frame, if I wanted to only see the entries one to three, I could use Pythonic slicing and do a oo.iloc.1:4 and these…
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.