Skip to content
Justice Tech School

concat

concat stacks DataFrames vertically or side by side.

Example
a = pd.DataFrame({"x": [1, 2]})
b = pd.DataFrame({"x": [3]})
print(pd.concat([a, b], ignore_index=True))
print(pd.concat([a, a], axis=1).shape)

Result

   x
0  1
1  2
2  3
(2, 2)

Exercise

Stack rows.

pd.([a, b])

Quiz Test

What does axis=1 do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.