Pandas join: Why you need a one-column DataFrame, not a Series

Pandas join: Why you need a one-column DataFrame, not a Series

Python Pandas gotcha: You can’t join a single column!

df1['x'].join(df2)  # Error!

Why? join() is a data frame method. A single column is a Series.

Solution: Use [[ ]] to get a one-column data frame:

df1[['x']].join(df2)  # Works!