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

Setting the index

The last step that you'll take in this chapter is to set the stop_datetime column as the DataFrame's index. By replacing the default index with a DatetimeIndex, you'll make it easier to analyze the dataset by date and time, which will come in handy later in the course!

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

Analyzing Police Activity with pandas

ดูคอร์ส

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

  • Set stop_datetime as the DataFrame index.
  • Examine the index to verify that it is a DatetimeIndex.
  • Examine the DataFrame columns to confirm that stop_datetime is no longer one of the columns.

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

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

# Set 'stop_datetime' as the index
ri.____(____, inplace=True)

# Examine the index
print(____)

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