Joining and filtering
Just as you might not always want all the data in a single table, you might not want all columns and rows that result from a JOIN. In this exercise, you'll use SQL to refine a data import.
Weather exacerbates some housing problems more than others. Your task is to focus on water leak reports in hpd311calls and assemble a dataset that includes the day's precipitation levels from weather to see if there is any relationship between the two. The provided SQL gets all columns in hpd311calls, but you'll need to modify it to get the necessary weather column and filter rows with a WHERE clause.
pandas is loaded as pd, and the database engine, engine, has been created.
Cet exercice fait partie du cours
Streamlined Data Ingestion with pandas
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Query to get hpd311calls and precipitation values
query = """
SELECT hpd311calls.*, ____
FROM hpd311calls
____ weather
____ hpd311calls.____ = ____;"""
# Load query results into the leak_calls dataframe
leak_calls = ____
# View the dataframe
print(leak_calls.head())