Skip to content

Commit 8bbe838

Browse files
ohad83jreback
authored andcommitted
BUG - Allow a mapper of type collections.abc.Mapping when using
Series.map
1 parent 27b713b commit 8bbe838

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pandas/core/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Base and utility classes for pandas objects.
33
"""
44
import builtins
5+
from collections import OrderedDict, abc
56
import textwrap
67
from typing import Dict, FrozenSet, List, Optional
78

@@ -1107,7 +1108,7 @@ def _map_values(self, mapper, na_action=None):
11071108
# we can fastpath dict/Series to an efficient map
11081109
# as we know that we are not going to have to yield
11091110
# python types
1110-
if isinstance(mapper, dict):
1111+
if isinstance(mapper, abc.Mapping):
11111112
if hasattr(mapper, "__missing__"):
11121113
# If a dictionary subclass defines a default value method,
11131114
# convert mapper to a lookup function (GH #15999).

0 commit comments

Comments
 (0)