Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit fd2e97a

Browse files
authored
Scale Series.count() (#578)
* Scale Series.count() * Add special case for ints which simply return len
1 parent 543c733 commit fd2e97a

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

sdc/datatypes/hpat_pandas_series_functions.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4551,14 +4551,22 @@ def hpat_pandas_series_count_str_impl(self, level=None):
45514551

45524552
return hpat_pandas_series_count_str_impl
45534553

4554+
if isinstance(self.data, types.Array) and isinstance(self.data.dtype, types.Integer):
4555+
def hpat_pandas_series_count_int_impl(self, level=None):
4556+
return len(self._data)
4557+
return hpat_pandas_series_count_int_impl
4558+
45544559
def hpat_pandas_series_count_impl(self, level=None):
45554560
"""
45564561
Return number of non-NA/null observations in the object
45574562
Returns number of unique elements in the object
45584563
Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_count
45594564
"""
4560-
data_no_nan = self._data[~numpy.isnan(self._data)]
4561-
return len(data_no_nan)
4565+
result = 0
4566+
for i in prange(len(self._data)):
4567+
if not numpy.isnan(self._data[i]):
4568+
result = result + 1
4569+
return result
45624570

45634571
return hpat_pandas_series_count_impl
45644572

sdc/tests/tests_perf/test_perf_series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def _test_case(self, pyfunc, name, total_data_length, data_num=1, input_data=tes
7575
usecase_params='A, B', data_num=2),
7676
TC(name='copy', size=[10 ** 8]),
7777
TC(name='corr', size=[10 ** 7],params='other', data_num=2),
78-
TC(name='count', size=[10 ** 7]),
78+
TC(name='count', size=[10 ** 8]),
7979
TC(name='cov', size=[10 ** 8], params='other', data_num=2),
8080
TC(name='cumsum', size=[10 ** 8]),
8181
TC(name='describe', size=[10 ** 7]),

0 commit comments

Comments
 (0)