Preparing the DataFrames
In this exercise, you'll prepare the traffic stop and weather rating DataFrames so that they're ready to be merged:
- With the
riDataFrame, you'll move thestop_datetimeindex to a column since the index will be lost during the merge. - With the
weatherDataFrame, you'll select theDATEandratingcolumns and put them in a new DataFrame.
Diese Übung ist Teil des Kurses
Analyzing Police Activity with pandas
Anleitung zur Übung
- Reset the index of the
riDataFrame. - Examine the head of
rito verify thatstop_datetimeis now a DataFrame column, and the index is now the default integer index. - Create a new DataFrame named
weather_ratingthat contains only theDATEandratingcolumns from theweatherDataFrame. - Examine the head of
weather_ratingto verify that it contains the proper columns.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# 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(____)