EnergieID / entsoe-py

Python client for the ENTSO-E API (european network of transmission system operators for electricity)
MIT License
427 stars 188 forks source link

Issue with pandas query_day_ahead_prices() #322

Closed DCJLN closed 6 months ago

DCJLN commented 7 months ago

With Pandas client, for Day-Ahead prices download (tested for Belgium prices) the query return KeyError: '60T'.


KeyError Traceback (most recent call last) Cell In[16], line 2 1 # DA prices ----> 2 DA_prices = client.query_day_ahead_prices(country_code, start=start, end=end) 3 """ 4 DA_prices = DA_prices.iloc[:-1] 5 DA_prices.index = DA_prices.index.tz_localize(None) 6 DA_prices.describe() 7 """

File ~\AppData\Local\anaconda3\envs\py311\Lib\site-packages\entsoe\decorators.py:124, in year_limited..year_wrapper(start, end, *args, *kwargs) 122 for _start, _end in blocks: 123 try: --> 124 frame = func(args, start=_start, end=_end, **kwargs) 125 if func.name != '_query_unavailability' and isinstance(frame.index, pd.DatetimeIndex): 126 # Due to partial matching func may return data indexed by 127 # timestamps outside _start and _end. In order to avoid (...) 132 # If there are repeating records in a single frame (e.g. due 133 # to corrections) then the result will also have them. 134 if is_first_frame:

File ~\AppData\Local\anaconda3\envs\py311\Lib\site-packages\entsoe\entsoe.py:1185, in EntsoePandasClient.query_day_ahead_prices(self, country_code, start, end, resolution) 1179 # we do here extra days at start and end to fix issue 187 1180 text = super(EntsoePandasClient, self).query_day_ahead_prices( 1181 country_code=area, 1182 start=start-pd.Timedelta(days=1), 1183 end=end+pd.Timedelta(days=1) 1184 ) -> 1185 series = parse_prices(text)[resolution] 1186 if len(series) == 0: 1187 raise NoMatchingDataError

File ~\AppData\Local\anaconda3\envs\py311\Lib\site-packages\entsoe\parsers.py:38, in parse_prices(xml_text) 36 for soup in _extract_timeseries(xml_text): 37 soup_series = _parse_timeseries_generic(soup, 'price.amount') ---> 38 series[soup_series.index.freqstr].append(soup_series) 40 for freq, freq_series in series.items(): 41 if len(freq_series) > 0:

KeyError: '60T'

fboerman commented 7 months ago

what versions are you using? this is usually an issue with an old version of pandas (which pip should enforce so thats a bit annoying...)

qnlzgl commented 6 months ago

I have got the same error, using pandas 2.2.1

tightdelay commented 6 months ago

same here. pd.version : '2.2.1'

client = EntsoePandasClient(api_key=API_KEY)
start = pd.Timestamp('20201201', tz ='UTC')
end = pd.Timestamp('20201202', tz ='UTC')
country_code_1 = 'AT'  # 
country_code_2 = 'DE_LU'  # 
country_code_3 = 'CZ'  # 

#day-ahead market prices (€/MWh)
DA_prices = client.query_day_ahead_prices(country_code_2, start=start,end=end)

KeyError: '15min'

fboerman commented 6 months ago

Also latest entsoe-py?

-------- Original Message -------- On 13 Apr 2024, 00:32, tightdelay wrote:

same here. pd.version : '2.2.1'

client = EntsoePandasClient(api_key=API_KEY) start = pd.Timestamp('20201201', tz ='UTC') end = pd.Timestamp('20201202', tz ='UTC') country_code_1 = 'AT' # country_code_2 = 'DE_LU' # country_code_3 = 'CZ' #

day-ahead market prices (€/MWh)

DA_prices = client.query_day_ahead_prices(country_code_2, start=start,end=end)

KeyError: '15min'

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

tightdelay commented 6 months ago

@fboerman You are right. Function is working fine with entsoe = 0.6.7 entsoe = 2.2.2

fboerman commented 6 months ago

Good to hear! Thought as much because this has happened before haha. And my own server uses this code too

-------- Original Message -------- On 13 Apr 2024, 20:45, tightdelay wrote:

@.***(https://github.com/fboerman) You are right. Function is working fine with entsoe = 0.6.7 entsoe = 2.2.2

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

qnlzgl commented 6 months ago

Thank you, tried version entsoe-py=0.6.7, issue solved for me.