Load entire tables
In the last exercise, you saw that data.db
has two tables. weather
has historical weather data for New York City. hpd311calls
is a subset of call records made to the city's 311 help line about housing issues.
In this exercise, you'll use the read_sql()
function in pandas
to load both tables. read_sql()
accepts a string of either a SQL query to run, or a table to load. It also needs a way to connect to the database, like the engine
in the provided code.
This exercise is part of the course
Streamlined Data Ingestion with pandas
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Load libraries
import pandas as pd
from sqlalchemy import create_engine
# Create the database engine
engine = create_engine('sqlite:///data.db')
# Load hpd311calls without any SQL
hpd_calls = ____(____, ____)
# View the first few rows of data
print(hpd_calls.head())