0

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.

Drise
  • 4,310
  • 5
  • 41
  • 66
  • 6
    This reads like obfuscated Python. –  Mar 19 '18 at 20:45
  • 1
    Can you provide a [mcve] with sample inputs and desired outputs? [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples). – pault Mar 19 '18 at 21:12

0 Answers0