Concatenation is the operation of stitching two or more DataFrames together along an axis—either stacking them vertically (adding more rows) or pasting them horizontally (adding more columns).
In Pandas, this is executed via pd.concat().
axis=0)The most common use case is combining monthly or regional files that share the same schema:
Output:
axis=1)When you have matching rows and want to attach additional feature columns:
When combining files from different branches or years, you can preserve their origin using the keys argument:
ignore_index=True do in pd.concat([df1, df2], ignore_index=True)?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Test your understanding of this lesson with 5 questions. Each question has one correct answer.
Combine 15 complete courses, 150 chapters, 541 topics, live SQL/Power BI/Tableau dashboards, and Scikit-Learn capstones at MSK Institute Shikohabad or Live Online.