Python
All Top 50 Python & Pandas Interview Questions#5
Safe JSON Ingestion and Error Handling in Python
EasyInterview Question #5
Write a function that accepts a list of raw JSON strings, parses valid payloads into dictionaries, logs/ignores invalid JSON lines gracefully, and returns all successfully extracted user IDs.
Input Table: json_lines
1 rows preview| raw_lines |
|---|
| {"user_id": 101},MALFORMED_JSON_STRING,{"user_id": 102} |
Expected Output Structure1 rows
| valid_user_ids |
|---|
| 101,102 |
Interview Context
Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.
Python 3.10 (Pandas)
Environment Ready
Click "Run & Test" to execute your Pandas code against the test assertions.