@@ -197,8 +197,16 @@ def __init__(self, data=None, index=None, dtype=None, name=None,
197
197
data = data .reindex (index , copy = copy )
198
198
data = data ._data
199
199
elif isinstance (data , dict ):
200
+ remap_to_mi = False
200
201
if data :
201
202
keys , values = zip (* compat .iteritems (data ))
203
+ # Workaround for #18485 - part 1/3
204
+ maybe_mi_keys = Index (list (keys ), tupleize_cols = True )
205
+ if isinstance (maybe_mi_keys , MultiIndex ):
206
+ remap_to_mi = True
207
+ keys = Index (list (keys ), tupleize_cols = False )
208
+ else :
209
+ keys = maybe_mi_keys
202
210
else :
203
211
if index is None :
204
212
index = Index ([])
@@ -208,6 +216,8 @@ def __init__(self, data=None, index=None, dtype=None, name=None,
208
216
if index is not None :
209
217
if not index .identical (s .index ):
210
218
s = s .reindex (index )
219
+ # Workaround for #18485 - part 2/3
220
+ remap_to_mi = False
211
221
else :
212
222
if not isinstance (data , OrderedDict ):
213
223
try :
@@ -216,6 +226,10 @@ def __init__(self, data=None, index=None, dtype=None, name=None,
216
226
pass
217
227
index = s .index
218
228
data = s ._data
229
+ # Workaround for #18485 - part 3/3
230
+ if remap_to_mi :
231
+ index = Index (list (s .index ), tupleize_cols = True )
232
+ data .set_axis (0 , index )
219
233
copy = False
220
234
dtype = None
221
235
elif isinstance (data , SingleBlockManager ):
0 commit comments