From 24fc4d9d4250f2bf452f4e0bbdcb688713fc67c1 Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Fri, 3 Oct 2025 12:52:33 +0200 Subject: [PATCH 1/2] feat: add suggestion to error message Signed-off-by: F.N. Claessen --- flexmeasures/data/models/reporting/pandas_reporter.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/flexmeasures/data/models/reporting/pandas_reporter.py b/flexmeasures/data/models/reporting/pandas_reporter.py index 1802fe9a16..3d70f65c17 100644 --- a/flexmeasures/data/models/reporting/pandas_reporter.py +++ b/flexmeasures/data/models/reporting/pandas_reporter.py @@ -349,8 +349,12 @@ def _any_empty(objs): if (_any_empty(args) or _any_empty(kwargs.values())) and skip_if_empty: self.data[df_output] = self.data[df_input] else: - self.data[df_output] = getattr(self.data[df_input], method)( - *args, **kwargs - ) + try: + self.data[df_output] = getattr(self.data[df_input], method)( + *args, **kwargs + ) + except TypeError as exc: + if "unhashable type" in str(exc) and method == "sum": + raise TypeError("Maybe use 'add' instead of 'sum'") from exc previous_df = df_output From e5dbee3608a2b222f78aad2fe66f0204b5b9b133 Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Fri, 3 Oct 2025 22:05:23 +0200 Subject: [PATCH 2/2] style: update suggestion Signed-off-by: F.N. Claessen --- flexmeasures/data/models/reporting/pandas_reporter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flexmeasures/data/models/reporting/pandas_reporter.py b/flexmeasures/data/models/reporting/pandas_reporter.py index 3d70f65c17..ff3bbb403f 100644 --- a/flexmeasures/data/models/reporting/pandas_reporter.py +++ b/flexmeasures/data/models/reporting/pandas_reporter.py @@ -355,6 +355,8 @@ def _any_empty(objs): ) except TypeError as exc: if "unhashable type" in str(exc) and method == "sum": - raise TypeError("Maybe use 'add' instead of 'sum'") from exc + raise TypeError( + "Consider using 'add' instead of 'sum' as the transformation method." + ) from exc previous_df = df_output