From 033dcb564beb97aa2252c3b772174478c31d70ee Mon Sep 17 00:00:00 2001 From: Frank Boerman Date: Mon, 7 Oct 2024 17:54:09 +0200 Subject: [PATCH] fixed a bug when there is no data for netpositions --- entsoe/entsoe.py | 4 +++- entsoe/parsers.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/entsoe/entsoe.py b/entsoe/entsoe.py index e1f970c..da0166c 100644 --- a/entsoe/entsoe.py +++ b/entsoe/entsoe.py @@ -23,7 +23,7 @@ warnings.filterwarnings('ignore', category=XMLParsedAsHTMLWarning) __title__ = "entsoe-py" -__version__ = "0.6.10" +__version__ = "0.6.11" __author__ = "EnergieID.be, Frank Boerman" __license__ = "MIT" @@ -1169,6 +1169,8 @@ def query_net_position(self, country_code: Union[Area, str], text = super(EntsoePandasClient, self).query_net_position( country_code=area, start=start, end=end, dayahead=dayahead) series = parse_netpositions(text, resolution=resolution) + if len(series) == 0: + raise NoMatchingDataError series = series.tz_convert(area.tz) series = series.truncate(before=start, after=end) return series diff --git a/entsoe/parsers.py b/entsoe/parsers.py index 58c7e38..69eb823 100644 --- a/entsoe/parsers.py +++ b/entsoe/parsers.py @@ -69,7 +69,8 @@ def parse_netpositions(xml_text, resolution): # take the absolute value and correct for region #TODO: possible change this or remove this warning after helpdesk got back to me series_all.append(factor*series.abs()) - + if len(series_all) == 0: + return pd.Series() series_all = pd.concat(series_all).sort_index() return series_all