From the course: Data Analysis with Python and Pandas
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
The .iloc accessor
From the course: Data Analysis with Python and Pandas
The .iloc accessor
- [Instructor] Alright, so in the last lesson I mentioned that I was going to introduce a couple methods that were preferred over traditional Python indexing. One of those is the iloc method, which is the preferred way to access values via their positional index. This method works even when series have a custom non integer index. So even when I pass an integer values on a series that has a text-based index, we'll still be looking positionally, which allows me to easily grab, let's say, the first five rows by slicing to a stop point of five. I don't need to worry about that index label. It's also a little bit more efficient than traditional Python slicing, and it's recommended by Pandas creators for data access. So here we have df. This could either be a series or a data frame to access values from, I'm showing data frame here because this iloc method applies to both series and data frames. When we're talking about a single series, all we have are rows, but when we start working with a…
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.
Contents
-
-
-
-
(Locked)
Series basics10m
-
(Locked)
pandas data types and type conversion6m 46s
-
(Locked)
Challenge: Data types and type conversion2m 23s
-
(Locked)
Solution: Data types and type conversion3m 5s
-
(Locked)
The series index and custom indices7m 6s
-
(Locked)
The .iloc accessor4m 33s
-
(Locked)
The .loc accessor7m 3s
-
(Locked)
Duplicate index values and resetting the index6m 33s
-
(Locked)
Challenge: Accessing data and resetting the index2m 1s
-
(Locked)
Solution: Accessing data and resetting the index2m 39s
-
(Locked)
Filtering series and logical tests8m 19s
-
(Locked)
Sorting series3m 45s
-
(Locked)
Challenge: Sorting and filtering series57s
-
(Locked)
Solution: Sorting and filtering series3m 24s
-
(Locked)
Numeric series operations6m 31s
-
(Locked)
Text series operations7m 4s
-
(Locked)
Challenge: Series operations1m 36s
-
(Locked)
Solution: Series operations3m 53s
-
(Locked)
Numerical series aggregation5m 43s
-
(Locked)
Categorical series aggregation3m 32s
-
(Locked)
Challenge: Series aggregation50s
-
(Locked)
Solution: Series aggregation4m 20s
-
(Locked)
Missing data representation in pandas4m 29s
-
(Locked)
Identifying missing data2m 15s
-
(Locked)
Fixing missing data9m 27s
-
(Locked)
Challenge: Missing data45s
-
(Locked)
Solution: Missing data1m 35s
-
(Locked)
Applying custom functions to series4m 6s
-
(Locked)
pandas where() vs. NumPy where()6m 3s
-
(Locked)
Challenge: apply() and where()1m 9s
-
(Locked)
Solution: apply() and where()4m 37s
-
(Locked)
Key takeaways1m 24s
-
(Locked)
-
-
-
-
-
-
-
-