Data Cleaning Reps

← All exercises

Population by Census region

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

The region column holds codes: 1 = Northeast, 2 = Midwest, 3 = South, 4 = West (Puerto Rico's code is X). For state-level rows, return the region name and total pop2024, largest first. Label anything else Other.

Hint

region is text, so compare with '1', '2' and so on.

Same question in Excel / Google Sheets

Helper column =SWITCH(B2,"1","Northeast","2","Midwest","3","South","4","West","Other"), then SUMIFS or a pivot.

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.

← Events per million residents