Skip to content
Advertisement

Pandas: Add column information based on length of another dataframe

I have two data frames. I want to add the columns from the second data frame to the first one by matching the column information in data frame 1.

The first data frame: dd

JavaScript

The second dataframe: df

JavaScript

There are 61 unique items in column libcs in dataframe1 and 61 rows in the second data frame. I want to merge based on the matching column information.

Expected Output:

JavaScript

I tried the below code but it seems like it is not working

JavaScript

Advertisement

Answer

Use merge

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement