FastPrepPrepare House Price Regression Data

Prepare House Price Regression Data

Capital One logoCapital One● MediumFULLTIMEOA

Problem statement

Prepare train_houses and test_houses for house-price regression. Return both transformed datasets in one table, with all training rows first and all test rows second. Add dataset as the first column, using "train" or "test".

  1. Compute the mean of the non-null training age values, round it down to an integer, and fill missing ages in both datasets with that value.
  2. Map "Poor", "Fair", "Good", and "Excellent" to 0, 1, 2, and 3.
  3. Using training rows only, standardize bedrooms, bathrooms, sqft_living, sqft_lot, floors, age, and num_views with the population standard deviation. Round standardized values to five decimal places; when a training standard deviation is 0, return 0 for that column in both datasets.

Keep house_id, waterfront, and price unchanged. Preserve a null test price as null.

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.

train_houses

Labeled training house features.

ColumnTypeNullableDescription
house_idPKIntegerNo—
bedroomsIntegerNo—
bathroomsIntegerNo—
sqft_livingIntegerNo—
sqft_lotIntegerNo—
floorsDecimalNo—
waterfrontIntegerNo—
ageIntegerYes—
num_viewsIntegerNo—
condition_nameTextNo—
priceDecimalYes—

test_houses

House features transformed with training-only statistics.

ColumnTypeNullableDescription
house_idPKIntegerNo—
bedroomsIntegerNo—
bathroomsIntegerNo—
sqft_livingIntegerNo—
sqft_lotIntegerNo—
floorsDecimalNo—
waterfrontIntegerNo—
ageIntegerYes—
num_viewsIntegerNo—
condition_nameTextNo—
priceDecimalYes—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
datasetTextNo—
house_idIntegerNo—
bedroomsDecimalNo—
bathroomsDecimalNo—
sqft_livingDecimalNo—
sqft_lotDecimalNo—
floorsDecimalNo—
waterfrontIntegerNo—
ageDecimalNo—
num_viewsDecimalNo—
conditionIntegerNo—
priceDecimalYes—

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

Constraints

  • Both input tables are non-empty.
  • At least one training age is non-null.
  • Every condition_name is "Poor", "Fair", "Good", or "Excellent".
  • Training prices are non-null; test prices may be null.
  • Every numeric input is finite.
  • Result row order is exact.

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

More Capital One problems

See Capital One hiring insights