Block 24: Filtering, Sorting & Value Counts
Slice and sort DataFrames to answer real questions.
Concepts
- Boolean filtering with & and | operators
- sort_values(by, ascending)
- value_counts() and unique()
- nlargest() and nsmallest()
Code Examples
See exercise below.
Exercise
Filter rows where sepal_length > 5 AND petal_width < 2. Sort by sepal_length descending. Find the 5 most common species in a dataset using value_counts.
Homework
Create a 'filtered_data.csv' of the top 20 rows by sepal_length. Wednesday