I got basic DataFrame:
df = pd.DataFrame([[1, 2],[3, 4],[5, 6],[7, 8]],
index=['A','B','C','D'], columns=['X','Y'])
I would like the map function to work on columns X & Y and obtain this:
X Y Chk
A 1 2 found A
B 3 4 found B
C 5 6 found C
D 7 8 found D
For this, I created a dict for 2 keys:
mapped = {1:{2:'found A'}, 3:{4:'found B'},5:{6:'found C'}, 7:{8:'found D'}}
And used the applymap method on the DataFrame:
df['Chk'] = df[['X','Y']].applymap(mapped)
Unfortunately, I got an error message:
TypeError: ("'dict' object is not callable", 'occurred at index X')
Is the code wrong, or is it the dict-based mapping that simply does not support more than 1 column ?