Skip to content
Advertisement

Data_Frame Error – ValueError: Can only compare identically-labeled Series objects

I have two data_frames, as below:

JavaScript
JavaScript

The task is to create a data_frame(below one), where I need to add df_marks['Int1/40'] & df_marks['Int2/40'], if df_name['Student_ID'] == df_marks['Student_ID']

JavaScript

I tried

JavaScript

But its giving error as,

JavaScript

Do we have any simple way to do this?

Regards, Deepak Dash

Advertisement

Answer

Use DataFrame.join with aggregated sum for new column in df_name:

JavaScript

Or solution without helper column:

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