Ask Anything Monday - Weekly Thread

Hi, I'm just getting started with Python and Pandas for data analysis and just had a question.

I have a df (teamdata)with a column (champions) that has five ID numbers in it that correspond to 5 names. I have a separate df (championdictionary) that has these ID numbers (key) and the corresponding actual names (id), is there a way I can lookup and replace the ID numbers with the names? I wrote this code to do it but it just replaces the fields with "nan" which I assume is an error message.

teamdata['champions'] = teamdata['champions'].map(championdictionary.set_index('key')['id'])

Note as well the ID numbers in df1 are separated by a space (eg. "10 312 54 12 321")

Could anyone give me some help with this one?

/r/learnpython Thread