Commit 6a5d9f8b authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

Fixed a bug where stats where not ordered

parent 488dd501
......@@ -65,13 +65,15 @@ class HeatmapTask(AnalyticTask):
# sort by ranking_value
df = pd.merge(df, stats[['feature', ranking_method]], how='left',
left_index=True, right_on='feature')
df = df.sort_values(ranking_method, ascending=False) \
.drop(ranking_method, axis=1)
df.sort_values(ranking_method, ascending=False, inplace=True)
df.drop(ranking_method, axis=1, inplace=True)
z_df = pd.merge(z_df, stats[['feature', ranking_method]], how='left',
left_index=True, right_on='feature')
z_df = z_df.sort_values(ranking_method, ascending=False) \
.drop(ranking_method, axis=1)
z_df.sort_values(ranking_method, ascending=False, inplace=True)
z_df.drop(ranking_method, axis=1, inplace=True)
stats.sort_values(ranking_method, ascending=False, inplace=True)
# discard rows according to max_rows
df = df[:max_rows]
......
......@@ -161,6 +161,7 @@ class TestHeatmap:
data = pd.DataFrame(data)
feature_col = data['feature'].tolist()
assert ['D', 'C', 'A', 'B', 'D', 'C', 'A', 'B'] == feature_col
assert ['D', 'C', 'A', 'B'] == result['stats']['feature']
def test_max_rows_works(self):
numerical_arrays = [
......@@ -182,3 +183,4 @@ class TestHeatmap:
data = pd.DataFrame(data)
feature_col = data['feature'].tolist()
assert ['D', 'C', 'D', 'C'] == feature_col
assert result['stats']['feature'] == ['D', 'C']
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment