Fill Missing Ages and Cities

Easy
Data Cleaning
Paytm
Google
Adobe

Fill Missing Ages and Cities

Given users(user_id, age, city), replace null age with 0 and null city with 'UNKNOWN'. Return the full DataFrame sorted by user_id asc.

Sample input

user_idagecity
1Hyderabad
2Mumbai
3
430Mumbai
5Delhi
6Mumbai
Browser Engine: Evaluates PySpark DataFrame & SQL logic locally in Pyodide WebAssembly.

Input data

1 DataFrame

These DataFrames are passed to solve(spark, dfs). Access one with dfs['name'].

df.users10 rows
user_id (int)age (int)city (string)
1nullHyderabad
2nullMumbai
3nullnull
430Mumbai
5nullDelhi
6nullMumbai
777Delhi
848Mumbai
9nullBengaluru
10nullnull

Return these columns

user_id(int)
age(int)
city(string)

Column names and order must match. Sort order is specified in the question.

Browser engine
Loading Python editor…
Click Run to try the sample cases, or Submit to check the hidden cases. First run caches the browser Python engine (~8–15s once); all code stays on your device.