I’m working with data that has two separate IDs per item. When we pull data from most sources, we get a PLU/SKU—however, in one of our sources, we get an item number from our on-prem point-of-sale system. To solve this by hand, we have a master list that contains both the PLU and item number for each item, as a sort of key.
I have a dataframe that lists these item numbers alongside each item’s quantity. What I need to do is search for the item number in the master list DF, grab the PLU from that row, and replace the original item number with the PLU. I’ve been looking into solutions all day and have failed to find something that I can comprehend. Would it be possible to iterate through each entry in the master list DF and then call a replace function on the item number DF? How would I do that, or something better? Thanks in advance!!
Here’s what the data looks like across both, just as reference:
final_purch:
PLU QTY 0 12345634 4 1 78901256 29 2 34567878 2
master_df:
ITEM PLU 0 123456 12345634 1 789012 78901256 2 345678 34567878
EDIT: This post has been flagged as having an answer in the Merging 101 post, but this is a little more complicated than just merging, I think. I don’t want to merge these. I want to reference the data in one to change the data in another, as there are duplicate entries with small bits of diverging data that would cause issues in a merge.
Advertisement
Answer
This got closed before I could get an answer, so I just ended up merging and totally changing my approach to remove the unneeded data. Not ideal in the way I was hoping, but it got the job done.