Search⌘ K
AI Features

Concatenate Values of Two DataFrames

Explore how to concatenate two pandas DataFrames with differing columns. Understand why pandas assigns float64 types when missing values appear and how it manages data types during concatenation. This lesson helps improve your skills in data manipulation with pandas.

We'll cover the following...

Try it yourself

Try executing the code below to see the result.

Python 3.8
import pandas as pd
df1 = pd.DataFrame([[1, 2], [3, 4]], columns=['a', 'b'])
df2 = pd.DataFrame([[5, 6], [7, 8]], columns=['b', 'c'])
df = pd.concat([df1, df2])
print(df.dtypes)

Explanation

If we look at the dtypes of df1 and df2, we’ll ...