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

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…

Contents