22Functions for preparing various inputs passed to the DataFrame or Series
33constructors before passing them to a BlockManager.
44"""
5- from collections import OrderedDict , abc
5+ from collections import abc
66
77import numpy as np
88import numpy .ma as ma
99
1010from pandas ._libs import lib
11- import pandas .compat as compat
12- from pandas .compat import PY36
1311
1412from pandas .core .dtypes .cast import (
1513 construct_1d_arraylike_from_scalar ,
@@ -235,7 +233,7 @@ def init_dict(data, index, columns, dtype=None):
235233 arrays .loc [missing ] = [val ] * missing .sum ()
236234
237235 else :
238- keys = com . dict_keys_to_ordered_list (data )
236+ keys = list (data . keys () )
239237 columns = data_names = Index (keys )
240238 arrays = (com .maybe_iterable_to_list (data [k ]) for k in keys )
241239 # GH#24096 need copy to be deep for datetime64tz case
@@ -331,16 +329,13 @@ def extract_index(data):
331329 have_raw_arrays = False
332330 have_series = False
333331 have_dicts = False
334- have_ordered = False
335332
336333 for val in data :
337334 if isinstance (val , ABCSeries ):
338335 have_series = True
339336 indexes .append (val .index )
340337 elif isinstance (val , dict ):
341338 have_dicts = True
342- if isinstance (val , OrderedDict ):
343- have_ordered = True
344339 indexes .append (list (val .keys ()))
345340 elif is_list_like (val ) and getattr (val , "ndim" , 1 ) == 1 :
346341 have_raw_arrays = True
@@ -352,7 +347,7 @@ def extract_index(data):
352347 if have_series :
353348 index = _union_indexes (indexes )
354349 elif have_dicts :
355- index = _union_indexes (indexes , sort = not ( compat . PY36 or have_ordered ) )
350+ index = _union_indexes (indexes , sort = False )
356351
357352 if have_raw_arrays :
358353 lengths = list (set (raw_lengths ))
@@ -531,7 +526,7 @@ def _list_of_dict_to_arrays(data, columns, coerce_float=False, dtype=None):
531526 """Convert list of dicts to numpy arrays
532527
533528 if `columns` is not passed, column names are inferred from the records
534- - for OrderedDict and (on Python>=3.6) dicts, the column names match
529+ - for OrderedDict and dicts, the column names match
535530 the key insertion-order from the first record to the last.
536531 - For other kinds of dict-likes, the keys are lexically sorted.
537532
@@ -551,8 +546,7 @@ def _list_of_dict_to_arrays(data, columns, coerce_float=False, dtype=None):
551546
552547 if columns is None :
553548 gen = (list (x .keys ()) for x in data )
554- types = (dict , OrderedDict ) if PY36 else OrderedDict
555- sort = not any (isinstance (d , types ) for d in data )
549+ sort = not any (isinstance (d , dict ) for d in data )
556550 columns = lib .fast_unique_multiple_list_gen (gen , sort = sort )
557551
558552 # assure that they are of the base dict class and not of derived
0 commit comments