Skip to content
Snippets Groups Projects
Commit 6a4d09f2 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

Fixed bug in filtering

parent 8bd7667f
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -109,7 +109,8 @@ class AnalyticTask(Task, metaclass=abc.ABCMeta):
:return: Filtered data frame.
"""
for key in filters:
df = df[df[key].isin(filters[key])]
if filters[key]:
df = df[df[key].isin(filters[key])]
return df
@staticmethod
......
......@@ -145,4 +145,3 @@ def get_meta_information(task_id: str) -> Tuple[Response, int]:
data_state = get_data_state_for_task_id(task_id, wait)
logger.debug("Successfully gather meta information. Sending response.")
return jsonify({'meta': data_state['meta']}), 200
......@@ -23,10 +23,13 @@ class TestAnalyticsTask:
def test_apply_filter(self):
df = pd.DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]],
columns=['A', 'B', 'C'])
filters = {'A': [1, 7], 'B': [2, 5, 8], 'C': [6, 9]}
df = self.task.apply_filters(df=df, filters=filters)
assert df.shape == (1, 3)
assert df.iloc[0].tolist() == [7, 8, 9]
filters1 = {'A': [1, 7], 'B': [2, 5, 8], 'C': [6, 9]}
filters2 = {'A': []}
df1 = self.task.apply_filters(df=df, filters=filters1)
df2 = self.task.apply_filters(df=df, filters=filters2)
assert df1.shape == (1, 3)
assert df1.iloc[0].tolist() == [7, 8, 9]
assert df2.shape == (3, 3)
def test_parse_value(self):
arg1 = '${"id": 123, "filters": {"foo": [1,2]}}$'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment