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.
Solution: Sorting and filtering series
From the course: Data Analysis with Python and Pandas
Solution: Sorting and filtering series
- [Instructor] All right, everybody. Our solution code is up on the right. Let's go ahead and take a look at the notebook. All right, so I got a little bit tricky with you guys here. The first thing we wanted to do is get the lowest 10 prices from our data. So we have oil series. If we sort on values, we'll end up sorting from lowest to highest. So, if we grab the first 10 rows from the sorted data, we'll end up with the 10 lowest prices. The next step was to sort them by date, starting with the most recent and ending with the oldest price. So what we need to do is then sort by index, and we want to sort in descending order, so most recent first. So, we're going to need to sort by our index into descending order. So we'll specify ascending equals false. And we now have our 10 lowest prices sorted by date with our most recent low price. This was May 10th, 2017. To our oldest low price, which was March 14th, 2017. Happy pie day. And now we want to filter our series down to match only…
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)
-
-
-
-
-
-
-
-