Practice / reshaping

Combine the Regions

easy

The Daily Grind keeps two regional revenue tables, east and west, with the same three columns — but the two teams happened to list their columns in a different order. Stack them into one DataFrame, safely.

east

west (note the column order)

Your task: return one DataFrame with all rows from both regions, using a name-safe union so the columns line up by name rather than position.

Assign your answer DataFrame to result. Row order doesn't matter.

eastinput DataFrame

Schema
columntype
storestring
amountdouble
taxdouble
Sample rows
storeamounttax
Boston101
Miami80.8

westinput DataFrame

Schema
columntype
storestring
taxdouble
amountdouble
Sample rows
storetaxamount
Denver0.66
Reno0.44
Expected output shape
storeamounttax· 4 rows
Hint

east.unionByName(west) stacks the two tables by column name, so it lines up correctly even though west lists its columns in a different order.

Lesson refresher

This problem builds on Reshaping Data (~7 min). Pop it open in a new tab if you want a quick recap.

Loading editor…
Hit Run to execute your code and see the output here.