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.
Cet exercice fait partie du cours
Python for R Users
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
import pandas as pd
# Load the country_timeseries dataset
ebola = pd.____('country_timeseries.csv')
# Inspect the Date column
print(ebola['Date'].dtype)