Puzzle 25: Hit and Run
Let's solve a pandas DataFrame using SQL.
We'll cover the following
Guess the output
Try to guess the output of the code below:
import sqlite3import pandas as pdconn = sqlite3.connect(':memory:')conn.executescript('''CREATE TABLE visits (day DATE, hits INTEGER);INSERT INTO visits VALUES('2020-07-01', 300),('2020-07-02', 500),('2020-07-03', 900);''')df = pd.read_sql('SELECT * FROM visits', conn)print('time span:', df['day'].max() - df['day'].min())
Quiz
Q
What is the output of the code above?
A)
time span: 2 days, 0:00:00
B)
time span: 3 days, 0:00:00
C)
TypeError
D)
ValueError
Get hands-on with 1300+ tech skills courses.