Where merge joins on a key, concat simply stacks DataFrames — vertically (more rows) or horizontally (more columns). It's how you combine monthly files or append new records.
Stacking rows
pd.concat([df_jan, df_feb, df_mar], ignore_index=True)# ignore_index=True renumbers the index 0..n instead of repeating labels
Side by side
pd.concat([df_features, df_labels], axis=1) # glue columns together
Key takeaways
- 01concat stacks DataFrames: axis=0 (default) adds rows, axis=1 adds columns.
- 02Use ignore_index=True when stacking rows to get a clean 0..n index.
- 03concat combines same-shaped tables; merge joins related tables on a key.
- 04It is the tool for combining per-period files or appending records.
