Skip to content

Commit

Permalink
updated the test as Series
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhengHe-007 committed Jan 23, 2025
1 parent 905315e commit a5c87e2
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions tests/test_missing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from pyeda.pymissing_values_summary import missing_values_summary

import pytest
import pandas as pd

Expand All @@ -16,23 +15,21 @@ def df():
return pd.DataFrame(data)



def test_missing_values_summary(df):
"""
Test for the missing_values_summary function.
"""
result = missing_values_summary(df)

# Expected results
expected_columns = ['Missing Count', 'Missing Percentage']
expected_index = ['B', 'A'] # Columns with missing values in descending order of missing count
expected_values = ['2 (50.0%)', '1 (25.0%)'] # Expected values in the Series

# Check if the result is a Series
assert isinstance(result, pd.Series), "Result should be a Series."

# Check if the resulting DataFrame has the correct structure
assert list(result.columns) == expected_columns
assert list(result.index) == expected_index
# Check if the resulting Series has the correct index
assert list(result.index) == expected_index, "Index does not match the expected order."

# Check the specific values
assert result.loc['B', 'Missing Count'] == 2
assert result.loc['B', 'Missing Percentage'] == 50.0
assert result.loc['A', 'Missing Count'] == 1
assert result.loc['A', 'Missing Percentage'] == 25.0
# Check the specific values in the Series
assert list(result.values) == expected_values, "Values in the Series do not match the expected output."

0 comments on commit a5c87e2

Please sign in to comment.