@@ -312,18 +312,18 @@ def fast_unique_multiple_list_gen(object gen, bint sort=True):
312
312
313
313
@ cython.wraparound (False )
314
314
@ cython.boundscheck (False )
315
- def dicts_to_array (dicts: list , _columns : list ):
315
+ def dicts_to_array (dicts: list , columns : list ):
316
316
cdef:
317
317
Py_ssize_t i, j, n
318
- object result, columns
318
+ object result, result_columns
319
319
object row
320
320
object col, onan = np.nan
321
321
dict d, nt_lookup
322
322
323
323
n = len (dicts)
324
- have_columns = len (_columns ) > 0
325
- columns = OrderedDict.fromkeys(list (_columns or []))
326
- result = OrderedDict((k, np.full(n, np.nan, dtype = ' O' )) for k in _columns )
324
+ have_columns = len (columns ) > 0
325
+ result_columns = OrderedDict.fromkeys(list (columns or []))
326
+ result = OrderedDict((k, np.full(n, np.nan, dtype = ' O' )) for k in columns )
327
327
328
328
nt_lookup = {}
329
329
for i in range (n):
@@ -332,22 +332,22 @@ def dicts_to_array(dicts: list, _columns : list):
332
332
d = row
333
333
for k in d:
334
334
v = d[k]
335
- if k not in columns :
335
+ if k not in result_columns :
336
336
if have_columns:
337
337
continue
338
- columns [k] = None
338
+ result_columns [k] = None
339
339
result[k] = np.full(n, np.nan, dtype = ' O' )
340
340
result[k][i] = v
341
341
elif hasattr (row, " _fields" ):
342
342
if type (row) not in nt_lookup:
343
343
l = []
344
344
for j, k in enumerate (row._fields):
345
- if k in columns or not have_columns:
345
+ if k in result_columns or not have_columns:
346
346
# include this field in result
347
347
l.append((k, j))
348
348
# create an array to store it
349
- if k not in columns :
350
- columns [k] = None
349
+ if k not in result_columns :
350
+ result_columns [k] = None
351
351
result[k] = np.full(n, np.nan, dtype = ' O' )
352
352
# save (column_name, index) pairs
353
353
nt_lookup[type (row)] = l
@@ -358,7 +358,7 @@ def dicts_to_array(dicts: list, _columns : list):
358
358
msg = " '%s ' at row %d is not a valid record type"
359
359
raise ValueError (msg % (type (row), i))
360
360
361
- return list (columns ), list (result.values())
361
+ return list (result_columns ), list (result.values())
362
362
363
363
364
364
def fast_zip (list ndarrays ):
0 commit comments