Examining the dataset
Throughout this course, you'll be analyzing a dataset of traffic stops in Rhode Island that was collected by the Stanford Open Policing Project.
Before beginning your analysis, it's important that you familiarize yourself with the dataset. In this exercise, you'll read the dataset into pandas, examine the first few rows, and then count the number of missing values.
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Analyzing Police Activity with pandas
คำแนะนำการฝึกหัด
- Import
pandasusing the aliaspd. - Read the file
police.csvinto a DataFrame namedri. - Examine the first 5 rows of the DataFrame (known as the "head").
- Count the number of missing values in each column: Use
.isnull()to check which DataFrame elements are missing, and then take the.sum()to count the number ofTruevalues in each column.
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Import the pandas library as pd
import ____ as ____
# Read 'police.csv' into a DataFrame named ri
ri = pd.____(____)
# Examine the head of the DataFrame
print(ri.____)
# Count the number of missing values in each column
print(ri.isnull().____)