I'm trying to apply what I call an override mapping to a dataframe. Essentially, I'd like the default value to be used from wkydf
HistTeamNm
except where my mapping table mpdf
has a different value. I've used similar logic before and it worked fine.
I've come up with the following:
wkydf['ManHistTeam']=wkydf['HistTeamNm']
wkydf.loc[wkydf.UsrIDWkYr.isin(mpdf.UsrIDWkYr),
['ManHistTeam']]=mpdf[['ManHistTeam']]
wkydf['InManMap']='N'
wkydf.loc[wkydf.UsrIDWkYr.isin(mpdf.UsrIDWkYr),['InManMap']]='Y'
So
wkydf.loc[wkydf.UsrIDWkYr.isin(mpdf.UsrIDWkYr),
['ManHistTeam']]=mpdf[['ManHistTeam']]
is currently giving my blanks but in the correct rows, so I'm fairly certain the logic identifying the row to override is working.
Also, when I change the mpdf[['ManHistTeam']]
to a static Y
, I get Y
where I'm expecting. I've also exported the mapping table and the strings are in the expected column. I can't figure out why the logic is returning blanks instead of the string from the mapping table.