Skip to content

Commit

Permalink
update filtering of approved data to search for any match
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamshaw, Scott Douglas committed Apr 10, 2024
1 parent 831c6cc commit 8beb8e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions hyswap/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ def filter_approved_data(data, filter_column=None):
"""
if filter_column is None:
raise ValueError("filter_column must be specified.")
return data.loc[((data[filter_column] == "A") |
(data[filter_column] == "A, e") |
(data[filter_column] == "A, R"))]
return data[data[filter_column].str.contains("A")]


def rolling_average(df, data_column_name, data_type,
Expand Down
5 changes: 3 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
class TestDataFilters:
def test_filter_approved_data(self):
"""Test the filter_approved_data function."""
data = {"a": ["A", "A", "P", "P"], "b": [1, 2, 3, 4]}
data = {"a": ["A", "A, e", "A, R", "A, [4]", "P", "P"],
"b": [1, 2, 3, 4, 5, 6]}
data_df = pd.DataFrame(data)
df = utils.filter_approved_data(data_df, filter_column="a")
assert df["b"].tolist() == [1, 2]
assert df["b"].tolist() == [1, 2, 3, 4]

def test_filter_approved_data_error(self):
"""Test the filter_approved_data function."""
Expand Down

0 comments on commit 8beb8e3

Please sign in to comment.