Skip to content

Commit 49637e1

Browse files
ohad83jreback
authored andcommitted
CLN: Checking is_dict_like instead of is abc.Mapping
1 parent 3074c8c commit 49637e1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pandas/core/base.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Base and utility classes for pandas objects.
33
"""
44
import builtins
5-
from collections import OrderedDict, abc
5+
from collections import OrderedDict
66
import textwrap
77
from typing import Dict, FrozenSet, List, Optional
88

@@ -21,6 +21,7 @@
2121
is_datetime64_ns_dtype,
2222
is_datetime64tz_dtype,
2323
is_extension_array_dtype,
24+
is_dict_like,
2425
is_list_like,
2526
is_object_dtype,
2627
is_scalar,
@@ -1108,7 +1109,7 @@ def _map_values(self, mapper, na_action=None):
11081109
# we can fastpath dict/Series to an efficient map
11091110
# as we know that we are not going to have to yield
11101111
# python types
1111-
if isinstance(mapper, abc.Mapping):
1112+
if is_dict_like(mapper):
11121113
if isinstance(mapper, dict) and hasattr(mapper, "__missing__"):
11131114
# If a dictionary subclass defines a default value method,
11141115
# convert mapper to a lookup function (GH #15999).

pandas/core/series.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
Data structure for 1-dimensional cross-sectional and time series data
33
"""
4-
from collections import abc
54
from io import StringIO
65
from shutil import get_terminal_size
76
from textwrap import dedent
@@ -252,7 +251,7 @@ def __init__(
252251
else:
253252
data = data.reindex(index, copy=copy)
254253
data = data._data
255-
elif isinstance(data, abc.Mapping):
254+
elif is_dict_like(data):
256255
data, index = self._init_dict(data, index, dtype)
257256
dtype = None
258257
copy = False

0 commit comments

Comments
 (0)