0

I'd like to assign index value in dataframe 2 (2nd screenshot) to dataframe 1 (1st screenshot).

dataframe 1

dataframe 2

All combinations of the three columns in dataframe 1 are contained in dataframe 2, so no worries about unmatched rows.

Anyone can help?

Really appreciate your time and help :)

Arist
  • 11
  • 3
  • you should include what you have tried and a little more explanation if you want a useful code snippet as an answer. However, you can probably sort this out yourself if you use pandas merge and set index. The docs have several examples. MERGE: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.merge.html SET INDEX: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.set_index.html?highlight=set_index#pandas.DataFrame.set_index – born_naked Jul 13 '21 at 16:56
  • Also note that your index, as opposed to a column called "index", needs to be unique so its probably not possible to set anything from your second DF (max number of unique values 87,528) as the index of the first DF because it has over 28 million unique values. – born_naked Jul 13 '21 at 17:00
  • @Arist Please Check -> https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples – Nk03 Jul 14 '21 at 04:38

0 Answers0