Skip to content

Commit 19f9d7d

Browse files
committed
removed '_concat_date_cols_sequence' func
1 parent 71d89f2 commit 19f9d7d

File tree

2 files changed

+10
-63
lines changed

2 files changed

+10
-63
lines changed

asv_bench/benchmarks/io/parsers.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ def time_check_datetimes(self, value):
2020

2121
class ConcatDateCols(object):
2222

23-
params = ([1234567890, 'AAAA'], [1, 2], [np.array, list])
24-
param_names = ['value', 'dim', 'container']
23+
params = ([1234567890, 'AAAA'], [1, 2])
24+
param_names = ['value', 'dim']
2525

26-
def setup(self, value, dim, container):
27-
count_elem = 10000
26+
def setup(self, value, dim):
27+
count_elem = 100000
2828
if dim == 1:
29-
self.object = (container([value] * count_elem),)
29+
self.object = (np.array([value] * count_elem),)
3030
if dim == 2:
31-
self.object = (container([value] * count_elem),
32-
container([value] * count_elem))
31+
self.object = (np.array([value] * count_elem),
32+
np.array([value] * count_elem))
3333

34-
def time_check_concat(self, value, dim, container):
34+
def time_check_concat(self, value, dim):
3535
_concat_date_cols(self.object)

pandas/_libs/lib.pyx

+2-55
Original file line numberDiff line numberDiff line change
@@ -2424,59 +2424,9 @@ cdef cnp.ndarray[object] _concat_date_cols_numpy(tuple date_cols,
24242424
return result
24252425

24262426

2427-
@cython.wraparound(False)
2428-
@cython.boundscheck(False)
2429-
cdef cnp.ndarray[object] _concat_date_cols_sequence(tuple date_cols,
2430-
Py_ssize_t rows_count,
2431-
Py_ssize_t col_count,
2432-
bint keep_trivial_numbers):
2433-
"""
2434-
Concatenates elements from sequences into strings.
2435-
2436-
Parameters
2437-
----------
2438-
date_cols : tuple of sequences
2439-
rows_count : Py_ssize_t
2440-
count of elements from sequences that will be concatenated
2441-
col_count : Py_ssize_t
2442-
count of sequences whose elements will be concatenated
2443-
keep_trivial_numbers : bool, default False
2444-
if True and len(date_cols) == 1, then
2445-
conversion (to string from integer/float zero) is not performed
2446-
2447-
Returns
2448-
-------
2449-
arr_of_rows : ndarray (dtype=object)
2450-
"""
2451-
cdef:
2452-
Py_ssize_t col_idx, row_idx
2453-
list list_to_join
2454-
cnp.ndarray[object] result
2455-
object[:] result_view
2456-
2457-
result = np.zeros(rows_count, dtype=object)
2458-
2459-
# create memoryview of result ndarray - more effecient indexing
2460-
result_view = result
2461-
2462-
if col_count == 1:
2463-
for row_idx, item in enumerate(date_cols[0]):
2464-
result_view[row_idx] = convert_to_unicode(item,
2465-
keep_trivial_numbers)
2466-
else:
2467-
list_to_join = [None] * col_count
2468-
for row_idx in range(rows_count):
2469-
for col_idx, array in enumerate(date_cols):
2470-
list_to_join[col_idx] = convert_to_unicode(array[row_idx],
2471-
False)
2472-
result_view[row_idx] = PyUnicode_Join(' ', list_to_join)
2473-
2474-
return result
2475-
2476-
24772427
def _concat_date_cols(tuple date_cols, bint keep_trivial_numbers=True):
24782428
"""
2479-
Concatenates elements from sequences in `date_cols` into strings.
2429+
Concatenates elements from numpy arrays in `date_cols` into strings.
24802430
24812431
Parameters
24822432
----------
@@ -2506,9 +2456,6 @@ def _concat_date_cols(tuple date_cols, bint keep_trivial_numbers=True):
25062456
rows_count = min(len(array) for array in date_cols)
25072457

25082458
if all(util.is_array(array) for array in date_cols):
2509-
# call specialized function to increase performance
25102459
return _concat_date_cols_numpy(date_cols, rows_count, col_count,
25112460
keep_trivial_numbers)
2512-
else:
2513-
return _concat_date_cols_sequence(date_cols, rows_count, col_count,
2514-
keep_trivial_numbers)
2461+
raise ValueError("not all elements from date_cols are numpy arrays")

0 commit comments

Comments
 (0)