Skip to content

Commit 80e40f8

Browse files
faicjreback
authored andcommitted
CLN16668: remove OrderedDefaultDict (#16939)
1 parent 6cee09e commit 80e40f8

File tree

2 files changed

+4
-27
lines changed

2 files changed

+4
-27
lines changed

pandas/compat/__init__.py

-25
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
given metaclass instead (and avoids intermediary class creation)
2222
2323
Other items:
24-
* OrderedDefaultDict
2524
* platform checker
2625
"""
2726
# pylint disable=W0611
@@ -373,30 +372,6 @@ def parse_date(timestr, *args, **kwargs):
373372
parse_date = _date_parser.parse
374373

375374

376-
class OrderedDefaultdict(OrderedDict):
377-
378-
def __init__(self, *args, **kwargs):
379-
newdefault = None
380-
newargs = ()
381-
if args:
382-
newdefault = args[0]
383-
if not (newdefault is None or callable(newdefault)):
384-
raise TypeError('first argument must be callable or None')
385-
newargs = args[1:]
386-
self.default_factory = newdefault
387-
super(self.__class__, self).__init__(*newargs, **kwargs)
388-
389-
def __missing__(self, key):
390-
if self.default_factory is None:
391-
raise KeyError(key)
392-
self[key] = value = self.default_factory()
393-
return value
394-
395-
def __reduce__(self): # optional, for pickle support
396-
args = self.default_factory if self.default_factory else tuple()
397-
return type(self), args, None, None, list(self.items())
398-
399-
400375
# https://github.com/pandas-dev/pandas/pull/9123
401376
def is_platform_little_endian():
402377
""" am I little endian """

pandas/core/panel.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import pandas.core.ops as ops
2020
import pandas.core.missing as missing
2121
from pandas import compat
22-
from pandas.compat import (map, zip, range, u, OrderedDict, OrderedDefaultdict)
22+
from pandas.compat import (map, zip, range, u, OrderedDict)
2323
from pandas.compat.numpy import function as nv
2424
from pandas.core.common import _try_sort, _default_index
2525
from pandas.core.frame import DataFrame
@@ -260,9 +260,11 @@ def from_dict(cls, data, intersect=False, orient='items', dtype=None):
260260
-------
261261
Panel
262262
"""
263+
from collections import defaultdict
264+
263265
orient = orient.lower()
264266
if orient == 'minor':
265-
new_data = OrderedDefaultdict(dict)
267+
new_data = defaultdict(OrderedDict)
266268
for col, df in compat.iteritems(data):
267269
for item, s in compat.iteritems(df):
268270
new_data[item][col] = s

0 commit comments

Comments
 (0)