เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Preparing the DataFrames

In this exercise, you'll prepare the traffic stop and weather rating DataFrames so that they're ready to be merged:

  1. With the ri DataFrame, you'll move the stop_datetime index to a column since the index will be lost during the merge.
  2. With the weather DataFrame, you'll select the DATE and rating columns and put them in a new DataFrame.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Analyzing Police Activity with pandas

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Reset the index of the ri DataFrame.
  • Examine the head of ri to verify that stop_datetime is now a DataFrame column, and the index is now the default integer index.
  • Create a new DataFrame named weather_rating that contains only the DATE and rating columns from the weather DataFrame.
  • Examine the head of weather_rating to verify that it contains the proper columns.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# Reset the index of 'ri'


# Examine the head of 'ri'
print(____)

# Create a DataFrame from the 'DATE' and 'rating' columns


# Examine the head of 'weather_rating'
print(____)
แก้ไขและรันโค้ด