Data Analysis with Python: From Raw Data to Real-World Insights
BOOK 2 · PROJECTS · CHAPTER 16

Chapter 16 exercises: Guided Real-World Investigations

On this page

Attempt these tasks before opening the worked answers. Use the chapter experiment notebook, or import NumPy as np and Pandas as pd in your own notebook. Retain your first attempt and explain each correction.

B2-16-E01 · Audit measurement completeness

Keep rows with the measurements required for a scatterplot without unnecessarily requiring sex.

df=pd.DataFrame({"mass":[3.,4.,None],"length":[1.,2.,3.],"sex":[None,"f","m"]})
One hint after an attempt

Name the measurements needed for this question.

B2-16-E02 · Classify uncertain catalogue dates

Classify before 1900, at/after 1900 and crossing the boundary, without inventing exact dates.

early=np.array([1890,1901,1899]);late=np.array([1895,1905,1902])
One hint after an attempt

Compare both interval bounds with the cutoff.

B2-16-E03 · Retain document identities

Explain why equal titles do not establish duplicate objects; check that IDs are unique and flag title repetition separately.

df=pd.DataFrame({"id":[1,2],"title":["Study","Study"]})
One hint after an attempt

Separate the entity key from the comparison text.

Reflect and get feedback

Explain one result without looking at the code. Identify one boundary case that would change your method. An optional tutor prompt is: “Here is my attempt at B2-16-E03. Give one hint about the violated assumption; do not give the solution yet.” Then use the worked answers.

Teaching edition · verified experiments · PDF and EPUB editions not generated.