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

Commit a9a0519

Browse files
authored
Add Boolean handling to Series.value_counts (#596)
* Add Boolean handling to Series.value_counts * Refactor test * Remove index sorting
1 parent 225e96d commit a9a0519

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

sdc/datatypes/hpat_pandas_series_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ def hpat_pandas_series_value_counts_str_impl(
13701370

13711371
return hpat_pandas_series_value_counts_str_impl
13721372

1373-
elif isinstance(self.dtype, types.Number):
1373+
elif isinstance(self.dtype, (types.Number, types.Boolean)):
13741374

13751375
series_dtype = self.dtype
13761376
def hpat_pandas_series_value_counts_number_impl(

sdc/tests/test_series.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2590,6 +2590,20 @@ def test_impl(S):
25902590
result = hpat_func(S).sort_index()
25912591
pd.testing.assert_series_equal(result, result_ref)
25922592

2593+
@skip_sdc_jit('Fails to compile with latest Numba')
2594+
def test_series_value_counts_boolean(self):
2595+
def test_impl(S):
2596+
return S.value_counts()
2597+
2598+
input_data = [True, False, True, True, False]
2599+
2600+
sdc_func = self.jit(test_impl)
2601+
2602+
S = pd.Series(input_data)
2603+
result_ref = test_impl(S)
2604+
result = sdc_func(S)
2605+
pd.testing.assert_series_equal(result, result_ref)
2606+
25932607
@skip_sdc_jit('Bug in old-style value_counts implementation for ascending param support')
25942608
def test_series_value_counts_sort(self):
25952609
def test_impl(S, value):

0 commit comments

Comments
 (0)