Recall & Review
beginner
What does the pandas
concat() function do when stacking DataFrames?It combines multiple DataFrames either vertically (one below another) or horizontally (side by side) into a single DataFrame.
Click to reveal answer
beginner
What parameter in
concat() controls whether DataFrames are stacked vertically or horizontally?The
axis parameter. axis=0 stacks vertically (rows), axis=1 stacks horizontally (columns).Click to reveal answer
intermediate
If DataFrames have different columns, what does
concat() do by default?It includes all columns from all DataFrames, filling missing values with
NaN where data is absent.Click to reveal answer
intermediate
How can you reset the index after stacking DataFrames with
concat()?Use the parameter
ignore_index=True in concat() to create a new continuous index in the combined DataFrame.Click to reveal answer
intermediate
What is the difference between
concat() and append() in pandas?append() is a simpler method to stack DataFrames vertically but is deprecated. concat() is more flexible and recommended for stacking.Click to reveal answer
Which
axis value stacks DataFrames vertically using concat()?✗ Incorrect
Setting axis=0 stacks DataFrames vertically (one below another).
What happens to columns not shared by all DataFrames when using
concat()?✗ Incorrect
Columns not present in all DataFrames appear with NaN where data is missing.
How do you combine DataFrames side by side using
concat()?✗ Incorrect
Setting axis=1 stacks DataFrames horizontally (side by side).
Which parameter resets the index after concatenation?
✗ Incorrect
ignore_index=True resets the index to a new continuous range.
Why is
concat() preferred over append()?✗ Incorrect
append() is deprecated; concat() is more flexible and recommended.
Explain how to stack two DataFrames vertically using pandas
concat(). Include how to handle index resetting.Think about stacking rows and making the index continuous.
You got /3 concepts.
Describe what happens when concatenating DataFrames with different columns using
concat().Consider how pandas handles missing data in combined tables.
You got /3 concepts.