ComenzarEmpieza gratis

Combining object columns

Currently, the date and time of each traffic stop are stored in separate object columns: stop_date and stop_time.

In this exercise, you'll combine these two columns into a single column, and then convert it to datetime format. This will enable convenient date-based attributes that we'll use later in the course.

Este ejercicio forma parte del curso

Analyzing Police Activity with pandas

Ver curso

Instrucciones del ejercicio

  • Use a string method to concatenate stop_date and stop_time (separated by a space), and store the result in combined.
  • Convert combined to datetime format, and store the result in a new column named stop_datetime.
  • Examine the DataFrame .dtypes to confirm that stop_datetime is a datetime column.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Concatenate 'stop_date' and 'stop_time' (separated by a space)
combined = ri.stop_date.____

# Convert 'combined' to datetime format
ri['stop_datetime'] = ____

# Examine the data types of the DataFrame
print(____)
Editar y ejecutar código