Appendix D — Practice Problem Solutions — Chapter 7

Author

Ryan M. Moore, PhD

Published

April 24, 2025

Modified

April 28, 2025

Solution Section 7.9.1

df = pd.DataFrame(state_cancer_data)

Solution Section 7.9.2

df["Cancer Deaths Per 100k"] = df["Cancer Deaths"] / df["Population"] * 100_000

Solution Section 7.9.3

df.query("`Cancer Deaths Per 100k` >= 180 and `Median Household Income` < 68_500")

Solution Section 7.9.4

df.plot(kind="scatter", x="Median Household Income", y="Cancer Deaths Per 100k")

Solution Section 7.9.5

df.plot(kind="scatter", x="Percent Aged 65+", y="Cancer Deaths Per 100k")