Data Cleaning Reps

← All exercises

Which rows are actually states?

Beginnertext codesState population estimates (U.S. Census Bureau, Vintage 2024)

The Census file mixes the nation, regions, divisions and states. State-level rows have sumlev = '040' (text, with a leading zero). How many such rows are there?

Hint

Try sumlev = 40 and sumlev = '040'. Which one works, and why?

Same question in Excel / Google Sheets

Watch out: Excel may turn 040 into 40 on import. Import the column as Text, then =SUMPRODUCT(--(A2:A67="040")).

Download the CSV from the datasets page. Column letters assume the CSV opens with its header in row 1.

Tip: Ctrl+Enter (⌘+Enter on Mac) checks your answer. Everything runs in your browser; nothing you type is sent anywhere.

← Best combined MPG per year (EVs excluded)Five most populous states (2024) →