Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to apply the cleaning function using pipe().
Pandas
cleaned_df = df.[1](remove_nulls) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using apply instead of pipe, which doesn't support chaining well.
Using map, which is for Series, not DataFrames.
✗ Incorrect
The pipe() method applies a function to the DataFrame, allowing chaining of cleaning steps.
2fill in blank
mediumComplete the code to chain two cleaning functions using pipe().
Pandas
cleaned_df = df.pipe(remove_nulls).[1](strip_whitespace) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using apply or map breaks the pipeline chain.
Using filter is for filtering rows, not chaining functions.
✗ Incorrect
Using pipe() again allows chaining the next cleaning function.
3fill in blank
hardFix the error in the pipeline by completing the code correctly.
Pandas
cleaned_df = df.pipe(remove_nulls).pipe([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Calling the function inside pipe causes errors.
Passing the DataFrame as argument manually is unnecessary.
✗ Incorrect
When using pipe(), pass the function name without calling it (no parentheses).
4fill in blank
hardFill both blanks to create a pipeline that removes nulls and converts column names to lowercase.
Pandas
cleaned_df = df.[1](remove_nulls).[2](lowercase_columns)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing pipe with apply or map breaks the chain.
Using filter is incorrect for applying functions.
✗ Incorrect
Use pipe() for both steps to chain cleaning functions smoothly.
5fill in blank
hardFill all three blanks to build a cleaning pipeline that removes nulls and strips whitespace.
Pandas
cleaned_df = df.[1](remove_nulls).[2]([3])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Calling functions inside pipe with parentheses.
Using apply instead of pipe for chaining.
✗ Incorrect
Use pipe() to chain functions and pass the function names without parentheses.