I am trying to compare two dataframes using merge function but I see there are issues with this.
For example, given below is how df1 is:
id,date,ref_col
101,1/7/2018,1011/7/2018
101,2/7/2018,1012/7/2018
101,3/7/2018,1013/7/2018
df2 has the below dataset:
id,date,ref_col
101,1/7/2018,1011/7/2018
101,3/7/2018,1013/7/2018
I am trying to merge using the below:
new_df = df1.merge(df2, left_on=['ref_col'], right_on=['ref_col'])
The above returns only one row but not both the rows. However if I manually check in a spreadsheet both the rows are exactly the same.
Expected output:
101,1/7/2018,1011/7/2018
101,3/7/2018,1013/7/2018
but it returns only
101,1/7/2018,1011/7/2018
Comments
Post a Comment