Merging two dataframes with inner join

Question:

I am trying to merge two dataframes using pandas merge function with inner join. H0002 and H0003 is equal to ordrenr and radnr in the second dataframe. df_1 has 268643 and df_2 has 203124 rows. When I merge them, the resulting dataframe has 5303556 rows.. I have tried to use drop_duplicates and dup, but the duplicates aren’t removed. How should I merge the two dataframes and retain a new dataframe with no duplicates?
my approach

Asked By: user17637519

||

Answers:

To drop duplicates use

merged_df.drop_duplicates(inplace=True)
Answered By: Kayvan Shah