5 Filtering a DataFrame
This chapter covers
- Reducing a
DataFrame
’s memory use - Extracting
DataFrame
rows by one or more conditions - Filtering a
DataFrame
for rows that include or exclude null values - Selecting column values that fall between a range
- Removing duplicate and null values from a
DataFrame
In chapter 4, we learned how to extract rows, columns, and cell values from a DataFrame
by using the loc
and iloc
accessors. These accessors work well when we know the index labels and positions of the rows/columns we want to target. Sometimes, we may want to target rows not by an identifier but by a condition or a criterion. We may want to extract a subset of rows in which a column holds a specific value, for example.
In this chapter, we’ll learn ...
Get Pandas in Action now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.