Skip to content

Commit e208be9

Browse files
committed
Hopefully speed up 2D case
1 parent e591104 commit e208be9

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

pandas/_libs/lib.pyx

+13-12
Original file line numberDiff line numberDiff line change
@@ -2427,8 +2427,7 @@ cpdef object _concat_date_cols(tuple date_cols,
24272427
for i, item in enumerate(array):
24282428
convert_and_set_item(item, i, result_view, keep_numbers)
24292429
else:
2430-
for i in range(sequence_size):
2431-
array = date_cols[i]
2430+
for i, array in enumerate(date_cols):
24322431
if not PyArray_Check(array):
24332432
all_numpy = 0
24342433
if len(array) < min_size or min_size == 0:
@@ -2437,24 +2436,26 @@ cpdef object _concat_date_cols(tuple date_cols,
24372436
if all_numpy:
24382437
iters = np.zeros(sequence_size, dtype=object)
24392438
iters_view = iters
2440-
for i in range(sequence_size):
2441-
iters_view[i] = PyArray_IterNew(date_cols[i])
2439+
for i, array in enumerate(date_cols):
2440+
iters_view[i] = PyArray_IterNew(array)
24422441

24432442
result = np.zeros(min_size, dtype=object)
24442443
result_view = result
24452444

24462445
list_to_join = [None] * sequence_size
24472446

2448-
for i in range(min_size):
2449-
if all_numpy:
2450-
for j in range(sequence_size):
2447+
if all_numpy:
2448+
for i in range(min_size):
2449+
for j, array in enumerate(date_cols):
24512450
it = <flatiter>iters_view[j]
2452-
item = PyArray_GETITEM(date_cols[j], PyArray_ITER_DATA(it))
2451+
item = PyArray_GETITEM(array, PyArray_ITER_DATA(it))
24532452
put_object_as_unicode(list_to_join, j, item)
24542453
PyArray_ITER_NEXT(it)
2455-
else:
2456-
for j in range(sequence_size):
2457-
put_object_as_unicode(list_to_join, j, date_cols[j][i])
2458-
result_view[i] = PyUnicode_Join(' ', list_to_join)
2454+
result_view[i] = PyUnicode_Join(' ', list_to_join)
2455+
else:
2456+
for i in range(min_size):
2457+
for j, array in enumerate(date_cols):
2458+
put_object_as_unicode(list_to_join, j, array[i])
2459+
result_view[i] = PyUnicode_Join(' ', list_to_join)
24592460

24602461
return result

0 commit comments

Comments
 (0)