Concatenate
concat stacks DataFrames vertically (axis=0) or side by side (axis=1). ignore_index renumbers the rows.
Example
import pandas as pd
import numpy as np
a = pd.DataFrame({'x': [1, 2]})
b = pd.DataFrame({'x': [3, 4]})
print(pd.concat([a, b], ignore_index=True))
print(pd.concat([a, b], axis=1).shape)Result
x 0 1 1 2 2 3 3 4 (2, 2)
Exercise
Stack tables.
pd.([a, b])
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.