Locked lesson.
About this lesson
There are different ways to combine various pieces of data within your data frame. In this video, we'll discuss concatenating.
Exercise files
Download this lesson’s related exercise files.
Concatenating, Merging, and Joining part 1.docx57.5 KB Concatenating, Merging, and Joining part 1 - Solution.docx
55.4 KB
Quick reference
Concatenating, Merging, and Joining part 1
Concatenation allows us to combine two or more DataFrames together.
When to use
Use the .concat() function whenver you want to combine two or more DataFrames.
Instructions
Given two DataFrames named df1 and df2, to concatenate them on rows:
pd.concat([df1, df2])
Given two DataFrames named df1 and df2, to concatenate them on columns:
pd.concat([df1, df2], axis=1)
Hints & tips
- Concat by Row: pd.concat([df1, df2])
- Concat by Column: pd.concat([df1, df2], axis=1)
Lesson notes are only available for subscribers.