Merging two DataFrames
The error message indicates that df2 is of type pd.Series. You need to convert df2 .to_frame() as .merge() needs a pd.DataFrame() input (see docs): while you probably also just could: Alternatively, you can use pd.DataFrame.join() which accepts a pd.Series.