Get startedGet started for free

Dates (I)

You will often come across timeseries data during your Data Science journey. It is important you know how to parse them correctly and Pandas provides convenient functions for you to deal with them. If you have a date column that is in the form of a string, you can easily convert it to a datetime format using the pd.to_datetime() function. You need to specify the format argument that specifies in which format the dates exist. If the dates are in the month/day/year format, you would use:

pd.to_datetime(df['date_column_as_string'], format='%m/%d/%Y')

Having dates in this format is far more desirable as you will see in the next exercise.

This exercise is part of the course

Python for R Users

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

import pandas as pd

# Load the country_timeseries dataset
ebola = pd.____('country_timeseries.csv')

# Inspect the Date column
print(ebola['Date'].dtype)
Edit and Run Code