I need to create a new column in Pandas that finds the value for a specific day from a specific week for a specific ID from prior data. Data looks like this:
ID / Day / Week / Value
1 / Mon / 5 / 10
1 / Tue / 5 / 12
1 / Wed / 5 / 17
2 / Mon / 5 / 12
2 / Tue / 5 / 14
2 / Wed / 5 / 12
3 / Mon / 5 / 16
3 / Tue / 5 / 19
3 / Wed / 5 / 22
1 / Mon / 6 / 12
1 / Tue / 6 / 17
1 / Wed / 6 / 16
2 / Mon / 6 / 15
2 / Tue / 6 / 15
2 / Wed / 6 / 20
3 / Mon / 6 / 10
3 / Tue / 6 / 14
3 / Wed / 6 / 17
1 / Mon / 7 / 12
1 / Tue / 7 / 19
1 / Wed / 7 / 22
2 / Mon / 7 / 13
2 / Tue / 7 / 14
2 / Wed / 7 / 25
3 / Mon / 7 / 11
3 / Tue / 7 / 16
3 / Wed / 7 / 20
Now let's say I want to create a new column called "Wk5Val" that always find and selects the value from Week 5 for the same day of the week for the same ID. For instance, for ID = 2, Day = Tue, Week=7, the value should be 14, since that's the Week 5 value for ID=2 & Day=Tue.
At this point, I've tried about a dozen different things and can't figure this one out. In my head, I'm thinking of it working equivalent to something like this:
df[(df.Day == df.Day) & (df.week == 5) & (df.ID == df.ID)]['Value'].values[0]
Except that will only work with specific values. I need this to work on every row in a Dataframe and adjust for the "Day" and "ID".
Is there any straight-forward way to do this?