diff --git a/pandas/compat/__init__.py b/pandas/compat/__init__.py index 9eacb9acef2c9..33b41d61aa978 100644 --- a/pandas/compat/__init__.py +++ b/pandas/compat/__init__.py @@ -21,7 +21,6 @@ given metaclass instead (and avoids intermediary class creation) Other items: -* OrderedDefaultDict * platform checker """ # pylint disable=W0611 @@ -373,30 +372,6 @@ def parse_date(timestr, *args, **kwargs): parse_date = _date_parser.parse -class OrderedDefaultdict(OrderedDict): - - def __init__(self, *args, **kwargs): - newdefault = None - newargs = () - if args: - newdefault = args[0] - if not (newdefault is None or callable(newdefault)): - raise TypeError('first argument must be callable or None') - newargs = args[1:] - self.default_factory = newdefault - super(self.__class__, self).__init__(*newargs, **kwargs) - - def __missing__(self, key): - if self.default_factory is None: - raise KeyError(key) - self[key] = value = self.default_factory() - return value - - def __reduce__(self): # optional, for pickle support - args = self.default_factory if self.default_factory else tuple() - return type(self), args, None, None, list(self.items()) - - # https://github.com/pandas-dev/pandas/pull/9123 def is_platform_little_endian(): """ am I little endian """ diff --git a/pandas/core/panel.py b/pandas/core/panel.py index d1f5b4587059c..69a8468552f54 100644 --- a/pandas/core/panel.py +++ b/pandas/core/panel.py @@ -19,7 +19,7 @@ import pandas.core.ops as ops import pandas.core.missing as missing from pandas import compat -from pandas.compat import (map, zip, range, u, OrderedDict, OrderedDefaultdict) +from pandas.compat import (map, zip, range, u, OrderedDict) from pandas.compat.numpy import function as nv from pandas.core.common import _try_sort, _default_index from pandas.core.frame import DataFrame @@ -260,9 +260,11 @@ def from_dict(cls, data, intersect=False, orient='items', dtype=None): ------- Panel """ + from collections import defaultdict + orient = orient.lower() if orient == 'minor': - new_data = OrderedDefaultdict(dict) + new_data = defaultdict(OrderedDict) for col, df in compat.iteritems(data): for item, s in compat.iteritems(df): new_data[item][col] = s