Title: Load An Excel File Into Pandas
Slug: load_excel_file_into_pandas
Summary: How to quickly load an Excel file into pandas.
Date: 2016-08-31 12:00
Category: Python
Tags: Basics
Authors: Chris Albon

Preliminaries


In [6]:
# Load library
import pandas as pd

Load Excel File


In [7]:
# Create URL to Excel file (alternatively this can be a filepath)
url = 'https://raw.githubusercontent.com/chrisalbon/simulated_datasets/master/data.xlsx'

# Load the first sheet of the Excel file into a data frame
df = pd.read_excel(url, sheetname=0, header=1)

# View the first ten rows
df.head(10)


Out[7]:
5 2015-01-01 00:00:00 0
0 5 2015-01-01 00:00:01 0
1 9 2015-01-01 00:00:02 0
2 6 2015-01-01 00:00:03 0
3 6 2015-01-01 00:00:04 0
4 9 2015-01-01 00:00:05 0
5 7 2015-01-01 00:00:06 0
6 1 2015-01-01 00:00:07 0
7 6 2015-01-01 00:00:08 0
8 9 2015-01-01 00:00:09 0
9 5 2015-01-01 00:00:10 0