Closed
Description
Are the following 2 methods equivalent? I have to introduce a lambda
to gain additional performance when dealing with map of category.
import pandas as pd
x = pd.Series(list('abcd') * 1000).astype('category')
mapper = {'a': 1, 'b': 2, 'c': 3, 'd': 4}
%timeit x.map(mapper)
# 1000 loops, best of 3: 1.11 ms per loop
%timeit x.map(lambda a: mapper[a])
# 1000 loops, best of 3: 291 µs per loop