NCA-ADS - Data Manipulation and Preparation (23% of the exam) - Section 1.1
Integrate, join, and manipulate data using cuDF and pandas.
Use cuDF and pandas to merge, join, and reshape tabular datasets on the GPU. Recognise when cuDF's drop-in pandas API accelerates large-scale data integration tasks without changing existing pandas code.
cuDFpandas
Practice question for this objective
lock_openFree sampleData Manipulation and Preparationmedium
A team maintains a large existing ETL script written against pandas that performs several merges, group-by aggregations, and column assignments on multi-gigabyte tables. They want GPU acceleration with the fewest possible edits to the script's logic, ideally without rewriting the pandas calls themselves. Which mechanism is purpose-built to deliver GPU acceleration for an existing pandas script with minimal code change?
AReplace every pandas DataFrame construction in the script with an explicit cuDF DataFrame construction and rewrite each operation against the cuDF API by hand.
BEnable the cudf.pandas accelerator so the existing pandas calls are dispatched to cuDF on the GPU where supported and fall back to pandas on the CPU otherwise, leaving the script's pandas code essentially unchanged.check_circle Correct
CWrap the whole pandas script in a Dask delayed graph so the scheduler dispatches the unchanged pandas calls to GPU workers automatically.
DMove the script onto a larger-memory CPU node and increase the number of worker threads, which gives pandas the same throughput as a GPU without changing the library.
The cudf.pandas accelerator runs existing pandas code on the GPU with cuDF where supported and falls back to CPU, needing almost no code change. cudf.pandas wraps the pandas API so that supported operations execute on the GPU through cuDF while unsupported ones fall back to CPU pandas, all behind the same pandas interface. This lets an existing pandas ETL script gain GPU acceleration without rewriting its operations against the cuDF API, which is exactly the minimal-change goal.
Why A is wrong: Porting to the cuDF API does give GPU acceleration, but it requires editing every operation in the script, which is the opposite of the minimal-change goal the team set.
Why B is correct: The cudf.pandas accelerator intercepts pandas operations and routes them to cuDF on the GPU when supported, falling back to CPU pandas when not, delivering acceleration with essentially no changes to the script's pandas logic.
Why C is wrong: Dask can distribute work, but wrapping pandas in Dask delayed produces a CPU pandas task graph; it does not transparently turn pandas calls into GPU operations, so this does not accelerate the existing calls on the device.
Why D is wrong: More CPU memory and threads can help marginally, but pandas operations are largely single-threaded and CPU-bound, so this neither matches GPU throughput nor provides the acceleration the team wants.
Answers that look right on this material and are not. Each one is a distractor from a different question in the NCA-ADS bank for this domain.
It raises an unsupported-operation error and halts the script, requiring the team to rewrite that call before the pipeline can run to completion.
errorWhy it is wrong: Halting on the first unsupported call would defeat the zero-change promise of the accelerator; this describes a stricter failure mode than cudf.pandas actually uses, so it is wrong.
Pass the pandas DataFrame directly to cudf.merge as the right-hand argument; cuDF will convert it automatically during the merge.
errorWhy it is wrong: Tempting because cuDF's merge signature resembles pandas, but cuDF does not silently convert a pandas object passed as the right-hand frame - it raises a TypeError, so the merge would fail before running.
Convert the cuDF DataFrame to a pandas DataFrame and apply scikit-learn PCA, then convert the result back to cuDF for the downstream steps.
errorWhy it is wrong: This produces correct components but forces a GPU-to-host copy and CPU computation, defeating the requirement to keep the reduction on the GPU and adding the host-device transfer overhead the data scientist wants to avoid.