Skip to content

Commit 300cc7e

Browse files
authored
keep parameter test
Testing the functionality of value_counts keep parameter.
1 parent cf3b9b8 commit 300cc7e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import pandas as pd
2+
import pytest
3+
4+
def test_value_counts_normalize():
5+
# Test data
6+
data = pd.Series([1, 1, 2, 2, 3, 3, 3, 4])
7+
8+
# Apply your function to the series (with the 'keep' parameter introduced)
9+
result = data.value_counts(normalize='keep') # Assuming your new feature is applied
10+
11+
# Expected output: Normalized value counts
12+
expected = pd.Series(
13+
{3: '3(0.375)', 1: '2(0.25)', 2: '2(0.25)', 4: '1(0.125)'},
14+
name="proportion" # Ensure the name is set here to match the result
15+
)
16+
17+
# Ensure both result and expected have the same name attribute
18+
pd.testing.assert_series_equal(result, expected, check_names=True)

0 commit comments

Comments
 (0)