Python - Load time series from CSV file using Pandas

By xngo on April 1, 2019

Here is how to load time series information from CSV file using Pandas. Assume that the data.csv file contains date, name, age and weight as follows:

2005-11-01 John 33 100.56
2005-11-02 Nikki 29 77.84

Here is the code to load the data.csv:

# Reference:
import pandas as pd
my_headers = ['date', 'name', 'age', 'weight']
my_dtypes = {'date': 'str', 'name': 'str', 'age': 'int', 'weight': 'float'}
my_parse_dates = ['date']
loaded_data = pd.read_csv('data.csv', sep=' ', header=None, names=my_headers, 
                            dtype=my_dtypes, parse_dates=my_parse_dates)

About the author

Xuan Ngo is the founder of He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.