Join Our 5-Week ML/AI Engineer Interview Bootcamp 🚀 led by ML Tech Leads at FAANGs
How would you replace null or missing payment_method values with "unknown" in appstore_transactions and return all columns ordered by user_id ascending and transaction_dt descending?
| Column Name | Type |
|---|---|
| transaction_id | int64 |
| user_id | int64 |
| app_name | object |
| transaction_dt | object |
| payment_method | object |
| price | float64 |
| device | object |
| rating | float64 |
| Column Name | Type |
|---|---|
| transaction_id | int64 |
| user_id | int64 |
| app_name | object |
| transaction_dt | datetime64[ns] |
| payment_method | object |
| price | float64 |
| device | object |
| rating | float64 |
Use pandas DataFrame operations
Keep all columns in output
Sort: user_id asc, transaction_dt desc
Look for a way to replace nulls in a single column with a constant string (e.g., a “fill missing” operation).
In pandas, fillna("unknown") on payment_method will replace NaN/None values without changing other columns.
After filling nulls, sort with multiple keys: sort_values(["user_id","transaction_dt"], ascending=[True, False]).