0

I'm trying to create a lambda function which uses the index value, references it to a dictionary containing that index value and returning the value of that key. When running I get the following 'TypeError: unhashable type: 'Series'.

Here is some code, what am I doing wrong pls?

results = {'John': 56, 'Jack':88, 'Jill':90}
exam = pd.DataFrame(['Math', 'Art', 'Music'], index=['John', 'Jack', 'Jill'], columns=['Subject'])
exam['results'] = exam.apply(lambda row: results[row])

0 Answers0