0

I have a very specific case to which the standard dataframe to dataframe column values replacement does not apply.

Here we go:

I have one dataframe with a bunch of IDs:

Dataframe 1 with item IDs

I want to replace the item(0-5) Ids in all rows with the item names from another dataframe.

Now comes the tricky part. The other dataframe is structured as per below, and the column names do not match one to one the values of the items from the first dataframe, so that I can easily filter them (I have hidden irrelevant columns for the sake of clarity).

Dataframe2 with Item Names

Let's take for example item0 value form the first dataframe, first row, which is: 1011. In the second dataframe the respective column is named: 1011.name and not 1011.

What I want to achieve is to replace the number "1011" in the first dataframe with the name of the ID from the "1011.name" value from the second dataframe, so that the first Dataframe value for 1011 is "Giant's Belt".

Note, that the structure of the second dataframe is not ideal, as the column labels start directly with the <itemid.property>. Not sure if, by restructuring it, I could achieve the end result easier.

Thx!!!

Timus
  • 10,974
  • 5
  • 14
  • 28
  • Please add some code that creates a sample of the dataframes you are working with https://stackoverflow.com/help/how-to-ask – Tzane Dec 02 '21 at 12:27
  • Please [do not post images of data](https://stackoverflow.com/help/how-to-ask), add the information as text (within code fences etc.) instead, ideally as a [mre](https://stackoverflow.com/help/minimal-reproducible-example) (also look [here](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples)). – Timus Dec 02 '21 at 14:23

0 Answers0