0
$\begingroup$

having two dataframes each having common column which is country_code. while merging it by 'inner' join, it's returns empty dataframe. but i can see there is many values are common like IND, USA....

pd.merge(df1, df2, on='country_code', how='inner')

checked the column name and the string not having any spaces. please help me on it.

$\endgroup$
4
  • 2
    $\begingroup$ It should work if thetevwere common values between the two dataframes. You want to double check if there were leading or trailing spaces in your data that is causing the merge not ko work. $\endgroup$ – Jayaram Iyer May 5 at 5:51
  • $\begingroup$ verified for the leading or trailing spaces on merging column. it's fine. seems strange like encoding issue. $\endgroup$ – Sathish Kumar D May 5 at 6:19
  • 2
    $\begingroup$ Could you please print few lines of each df $\endgroup$ – 10xAI May 5 at 16:14
  • $\begingroup$ Can it be, that in one of them the strings are not strings but bytes, like b"IND", b"USA", b"CAN"? I don't think that it is a encoding issue. Strings have no encoding. Bytes have. $\endgroup$ – Arpad Horvath May 5 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.