Skip to content

Commit

Permalink
CLN16668: remove OrderedDefaultDict (pandas-dev#16939)
Browse files Browse the repository at this point in the history
  • Loading branch information
faic authored and 3553x committed Jul 16, 2017
1 parent c2654fe commit f53cd54
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
25 changes: 0 additions & 25 deletions pandas/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
given metaclass instead (and avoids intermediary class creation)
Other items:
* OrderedDefaultDict
* platform checker
"""
# pylint disable=W0611
Expand Down Expand Up @@ -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 """
Expand Down
6 changes: 4 additions & 2 deletions pandas/core/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f53cd54

Please sign in to comment.