Recall & Review
beginner
What does the
concat() function do in pandas?The
concat() function joins multiple DataFrames together either vertically (stacking rows) or horizontally (stacking columns).Click to reveal answer
beginner
How do you stack two DataFrames vertically using
concat()?Use
pd.concat([df1, df2]) to stack rows of df2 below df1. By default, it stacks vertically (axis=0).Click to reveal answer
beginner
What parameter controls whether
concat() stacks DataFrames horizontally or vertically?The
axis parameter: axis=0 stacks vertically (rows), axis=1 stacks horizontally (columns).Click to reveal answer
intermediate
What happens if the DataFrames have different columns when stacked vertically with
concat()?Missing columns in each DataFrame become
NaN in the result, so all columns from all DataFrames appear.Click to reveal answer
intermediate
How can you reset the index after stacking DataFrames with
concat()?Use
ignore_index=True inside concat() to reset the index in the combined DataFrame.Click to reveal answer
What is the default axis value for
pd.concat() when stacking DataFrames?✗ Incorrect
The default axis=0 stacks DataFrames vertically by rows.
If two DataFrames have different columns, what does
concat() do when stacking vertically?✗ Incorrect
Missing columns are filled with NaN so all columns appear in the result.
How do you stack DataFrames side-by-side (horizontally) using
concat()?✗ Incorrect
Setting axis=1 stacks DataFrames horizontally by columns.
What does
ignore_index=True do in concat()?✗ Incorrect
It resets the index so the new DataFrame has a continuous index starting at 0.
Which pandas function is used to stack DataFrames?
✗ Incorrect
concat() is used to stack DataFrames either vertically or horizontally.
Explain how to stack two DataFrames vertically using
concat() and how to handle their indexes.Think about stacking rows and index resetting.
You got /3 concepts.
Describe what happens when you stack DataFrames with different columns using
concat().Consider how pandas handles missing data in combined DataFrames.
You got /3 concepts.