Title: Importing an HTML table into pandas
Slug: pandas_import_html_table
Summary: Importing an HTML table into pandas
Date: 2016-05-01 12:00
Category: Data Wrangling
Tags: Basics
Authors: Chris Albon
In [4]:
# Import the required module
import pandas as pd
In [5]:
# Create a variable with the url to the website contain the html table
url = "http://www.w3schools.com/html/html_tables.asp"
In [6]:
# Read the html table into pandas
data = pd.read_html(url, header=0)
The resulting data will be a list of dataframe objects
In [7]:
# View the data
data
In [ ]:
# Select the first (and in this case only) dataframe object
data[0]