Chapter 1 Exploratory Data Analysis
The thesis of this book is we can use data to answer questions, resolve debates, and make better decisions.
This chapter introduces the steps weโll use to do that: loading and validating data, exploring, and choosing statistics that measure what we are interested in. As an example, weโll use data from the National Survey of Family Growth (NSFG) to answer a question I heard when my wife and I were expecting our first child: do first babies tend to arrive late?
from os.path import basename, exists
def download(url):
filename = basename(url)
if not exists(filename):
from urllib.request import urlretrieve
local, _ = urlretrieve(url, filename)
print("Downloaded " + local)
download("https://github.com/AllenDowney/ThinkStats/raw/v3/nb/thinkstats.py")
try:
import empiricaldist
except ImportError:
%pip install empiricaldist
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from IPython.display import HTML
from thinkstats import decorate
