FastPrepBuild House Viewing Features

Build House Viewing Features

Capital One logoCapital One● MediumFULLTIMEOA

Problem statement

Normalize the reported column-name variants in houses_0 through houses_3, combine the four house partitions, and add recent viewing activity.

Use view dates from 2023-03-16 through 2023-04-15, inclusive. Count qualifying rows in house_views for each house_id. Add the count as num_views; houses with no qualifying view receive 0.

Return the declared canonical columns, sorted by house_id ascending.

Table schema

Pandas

Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.

houses_0

House partition 0 with its source-visible column spellings.

ColumnTypeNullableDescription
house_idIntegerNo—
bedroomsIntegerNo—
bathroomsDecimalNo—
sqft_livingIntegerNo—
sqft_lotIntegerNo—
floorsDecimalNo—
waterfrontIntegerNo—
ageIntegerNo—
priceDecimalNo—

houses_1

House partition 1 with its source-visible column spellings.

ColumnTypeNullableDescription
houseidIntegerNo—
bed_roomsIntegerNo—
bath_roomsDecimalNo—
sqftlivingIntegerNo—
sqft_lotIntegerNo—
floorsDecimalNo—
water_frontIntegerNo—
ageIntegerNo—
priceDecimalNo—

houses_2

House partition 2 with its source-visible column spellings.

ColumnTypeNullableDescription
house_idIntegerNo—
bedroomsIntegerNo—
bathroomsDecimalNo—
sqft_livingIntegerNo—
sqftlotIntegerNo—
floorDecimalNo—
waterfrontIntegerNo—
house_ageIntegerNo—
priceDecimalNo—

houses_3

House partition 3 with its source-visible column spellings.

ColumnTypeNullableDescription
house_idIntegerNo—
bedroomsIntegerNo—
bathroomsDecimalNo—
living_sqftIntegerNo—
lot_sqftIntegerNo—
floorsDecimalNo—
waterfrontIntegerNo—
ageIntegerNo—
house_priceDecimalNo—

house_views

House-view events; one viewer may view the same house more than once.

ColumnTypeNullableDescription
viewer_idIntegerNo—
house_idIntegerNo—
view_dateDateNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
house_idIntegerNo—
bedroomsIntegerNo—
bathroomsDecimalNo—
sqft_livingIntegerNo—
sqft_lotIntegerNo—
floorsDecimalNo—
waterfrontIntegerNo—
ageIntegerNo—
priceDecimalNo—
num_viewsIntegerNo—

Row order: must match exactly. Numeric tolerance: 0.

Constraints

  • house_id values are unique across all four house partitions.
  • Every house_views.house_id identifies a supplied house.
  • Every view_date is a valid ISO calendar date.
  • The listed source-column variants are the only spellings that require normalization.
  • Result row order is exact.

Source note: Original Capital One data-science assessment task (carousel slide 2).

More Capital One problems

See Capital One hiring insights