Skip to content

Commit 896b17e

Browse files
committed
Normalize parameter of value_counts edited.
1 parent 3d69af3 commit 896b17e

File tree

1 file changed

+22
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)