-1

I have two dataframes with Pandas python which i am trying to join / merge/ concat/ ..

df1 with repeating urls in col1 and domain names in col2 , other columns contain information to be preserved

df2 which contains only unique domains from df1 and some extra information in col3 col4

I am trying all combinations of merge / join or concat to get all information in df2 - col3, col4 against respective domains in df1 ( which has repeating urls and domains in columns)

desired result : everytime the domain is matched, relevant information in col3, col4 is matched in resultant df

I am not sure if any map() with dictionary or any join merge or any function that can help me in this case. If someone has any clue, please help, I have already tried multiple stackoverflow articles on pandas df merge and join but does not helps.

Abhinav Kumar
  • 177
  • 2
  • 5
  • 22

1 Answers1

-1

I can't understand if "domain" is a simple column or the index of df2. If it is a column:

pd.merge(df2, df1, how="left", on="domain")

If "domain" is the index:

pd.merge(df2, df1, how="left", left_index=True, right_on="domain")

I hope this is useful. Let me know if it solves your question