Skip to content

Commit

Permalink
BUG: workaround for #18485
Browse files Browse the repository at this point in the history
  • Loading branch information
toobaz committed Nov 26, 2017
1 parent 3afd05c commit 6d701ec
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,16 @@ def __init__(self, data=None, index=None, dtype=None, name=None,
data = data.reindex(index, copy=copy)
data = data._data
elif isinstance(data, dict):
remap_to_mi = False
if data:
keys, values = zip(*compat.iteritems(data))
# Workaround for #18485 - part 1/3
maybe_mi_keys = Index(list(keys), tupleize_cols=True)
if isinstance(maybe_mi_keys, MultiIndex):
remap_to_mi = True
keys = Index(list(keys), tupleize_cols=False)
else:
keys = maybe_mi_keys
else:
if index is None:
index = Index([])
Expand All @@ -208,13 +216,19 @@ def __init__(self, data=None, index=None, dtype=None, name=None,
if index is not None:
if not index.equals(s.index):
s = s.reindex(index)
# Workaround for #18485 - part 2/3
remap_to_mi = False
elif not isinstance(data, OrderedDict):
try:
s = s.sort_index()
except TypeError:
pass
data = s._data
index = s.index
# Workaround for #18485 - part 3/3
if remap_to_mi:
index = Index(list(s.index), tupleize_cols=True)
data.set_axis(0, index)
copy = False
dtype = None
elif isinstance(data, SingleBlockManager):
Expand Down

0 comments on commit 6d701ec

Please sign in to comment.