OSUKED / ElexonDataPortal

Python wrapper for the Elexon/BMRS API
https://osuked.github.io/ElexonDataPortal
MIT License
52 stars 14 forks source link

cannot import name 'AggFuncTypeDict' from 'pandas._typing' (/usr/local/lib/python3.7/dist-packages/pandas/_typing.py) #9

Closed KrishnaMohinani closed 2 years ago

KrishnaMohinani commented 3 years ago

Hello,

Thanks for this amazing package. I am trying to do get_B1760 but unfortunately it gives me an error and also it shows the warning 'Data request was successful but no content was returned'

Anyway to fix this problem?

Thank you.

AyrtonB commented 3 years ago

Hi @KrishnaMohinani, I'm glad you've found the package useful.

Could you post the code you used (without the API key) as well as the error so I can better help you, thanks.

KrishnaMohinani commented 3 years ago

Hi @AyrtonB,

I think I have fixed the issue. Thanks anyways

CorentinJankowiak commented 2 years ago

Hi @KrishnaMohinani and @AyrtonB,

I seem to be facing the exact same issue and would be quite interested in how you managed to fix that, @KrishnaMohinani.

Here's the code I am using:

from ElexonDataPortal import api import pandas as pd

client = api.Client('my_API_key') start_date = '2022-01-01' end_date = '2022-01-02'

df = client.get_B1760(start_date, end_date)

Which returns: B1760: 0%| | 0/48 [00:00<?, ?it/s]C:\Users\corentin.jankowiak\AppData\Roaming\Python\Python37\site-packages\ElexonDataPortal\dev\utils.py:29: UserWarning: Data request was succesful but no content was returned warn(f'Data request was succesful but no content was returned') B1760: 100%|██████████| 48/48 [00:13<00:00, 3.54it/s]

Same result with 'get_BOD', 'get_B1740', and with other start/end date values, however I do get a non-empty response with 'get_B0610', and other streams.

Thanks for the work in building this module, very useful!

KrishnaMohinani commented 2 years ago

Hi @CorentinJankowiak,

I don't exactly remember how I fixed the issue but I also used another package: https://github.com/GiorgioBalestrieri/elexon_api_tool

Check this out and I think you should be able to extract data from elexon portal quite easily.

AyrtonB commented 2 years ago

Hi Both,

@CorentinJankowiak are you able to retrieve data for those dates when making a raw request using the inbuilt requests library? Sometimes B1740/60 and BOD can be a bit slower to update (though if you're querying January I would expect it to be there). If its being returned within those raw requests then I'll dig in to why they're not being passed through the wraper.

CorentinJankowiak commented 2 years ago

Hi both, thanks a lot for the quick responses!

@AyrtonB, I tried a number of date ranges with the same outcome so I doubt it comes from slow updates from Elexon's side. Otherwise, not sure if that's what you meant but I've tried using the 'raw' method as follows:

from ElexonDataPortal import api

api_key = my_api_key

r = api.orchestrator.raw.get_BOD( APIKey=api_key, SettlementDate='2020-01-01', ServiceType='csv', SettlementPeriod= '*' )

df = pd.read_csv(io.StringIO(r.content.decode('utf-8')), skiprows=1)

df.head(3)

I may be doing it wrong, but it throws the following error: "EmptyDataError: No columns to parse from file" - which seems consistent with the original error.

@KrishnaMohinani Thanks for the recommendation - I gave it a try, not as user friendly but seems to be working for the data streams I'm interested in!

Cheers

AyrtonB commented 2 years ago

The problem stems from the fact that the default parameters are auto-populated from Elexon's documentation, if you specify '' (all) as the value then data will be returned. I've just pushed an updated version to pypi where these defaults are now set to ''.

image
CorentinJankowiak commented 2 years ago

Works now :) thanks, @AyrtonB!

AyrtonB commented 2 years ago

That's great! Thanks for confirming, I'll now close this PR