You must clean 100 million rows: strip whitespace, fix date formats and drop duplicates. Which approach is fastest on a GPU workstation?
- Exam domain
- Data Preparation17% of the exam
- Difficulty
- Medium
- In this mock
- 8 questions on this domainPractise this domain
Why the exam asks this
Data Preparation (17% of the exam)
Objective in the exam guide: Performing data cleansing and preprocessing using CuDF and pandas
Cleansing with cuDF and pandas is named.
Why C is the answer
Vectorized cuDF string and datetime operations plus drop_duplicates
cuDF provides vectorized string, datetime and deduplication operations on the GPU. Row-wise Python apply is slow.
Remember: Vectorized cuDF operations clean data fast.
How it works
Data cleansing and preprocessing use vectorized cuDF and pandas operations.
In detail
- Vectorize, do not loop.
- cuDF has string and datetime methods.
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. Use pandas apply with a Python function per row so each row can be handled individuallyWrongMost tempting
Row-wise apply is the slowest path.
Why it tempts: apply is a familiar pandas habit.
B. Write each row to a database and clean it with stored proceduresWrong
Round trips to a database add overhead.
C. Vectorized cuDF string and datetime operations plus drop_duplicatesRight
Vectorized cuDF operations clean data fast.
D. Clean a 1% sample and assume the rest is fineWrong
Sampling leaves dirty data.
Use case
An illustrative scenario, not a real incident.
Illustrative: vectorized cuDF cleaning finishes in 90 seconds versus 2 hours with apply.
See it in different ways
flowchart LR S0["Load with cuDF"] --> S1["Strip strings"] --> S2["Parse dates"] --> S3["Drop duplicates"] --> S4["Validate counts"]
How to read this chart
- Read it in order: Load with cuDF, then Strip strings, then Parse dates, then Drop duplicates, then Validate counts.
mindmap
root(("cuDF cleaning"))
n1["Strings"]
n2["strip"]
n3["lower"]
n4["replace"]
n5["Dates"]
n6["to_datetime"]
n7["Rows"]
n8["drop_duplicates"]
n9["dropna"]How to read this chart
- The centre is "cuDF cleaning".
- "Strings" covers "strip", "lower", "replace".
- "Dates" covers "to_datetime".
- "Rows" covers "drop_duplicates", "dropna".