When we are taking the measure of our data and otherwise answering the question, "How does it look?", we are constantly zooming in and out. We are looking at aggregated numbers and particular rows. But there are also important data issues that are only obvious at an intermediate zoom level, issues that we only notice when looking at some subset of rows. This recipe demonstrates how to use the pandas tools for detecting data issues in subsets of our data.
We will continue working with the NLS data in this recipe.
How to do it...
We will go over several techniques for selecting rows in a pandas DataFrame.
numpy, and load the
>>> import pandas as pd >>> import numpy as np >>> nls97 = pd.read_csv("data/nls97.csv") >>> nls97.set_index("personid", inplace=True)
- Use slicing to start at the 1001st row and go to the 1004th row: