Open srennug opened 11 months ago
Thanks for adding this, I think you need to give it some start and end dates with timezones.
So something like this
start_date = '2020-01-01T00:00:00+00:00'
end_date = '2020-01-02T00:00:00+00:00'
Do you want to try that and let me know?
Unfortunately, it still gives the same error.
I went back to start_date = '2020-01-01' end_date = '2020-01-02' and it worked for me
What python version you using? What pandas version you got installed?
I ran it on python 3.8, and pandas 1.5.3
. Both of these are a bit out of date
When I upgraded to pandas==2.1.1
, it worked also. I have ElexonDataPortal-2.0.16
installed
Could you paste the full error here, and we can try to work out where it is going wrong
runcell(0, '/Users/tomelder/untitled0.py') PHYBMDATA: 100%|██████████| 95/95 [00:24<00:00, 3.88it/s] Traceback (most recent call last):
File "/Users/tomelder/untitled0.py", line 16, in
File "/Users/tomelder/opt/anaconda3/lib/python3.9/site-packages/ElexonDataPortal/api.py", line 1573, in get_PHYBMDATA df = orchestrator.query_orchestrator(
File "/Users/tomelder/opt/anaconda3/lib/python3.9/site-packages/ElexonDataPortal/dev/orchestrator.py", line 413, in query_orchestrator df = request_func(
File "/Users/tomelder/opt/anaconda3/lib/python3.9/site-packages/ElexonDataPortal/dev/orchestrator.py", line 84, in SP_and_date_request df = if_possible_parse_local_datetime(df)
File "/Users/tomelder/opt/anaconda3/lib/python3.9/site-packages/ElexonDataPortal/dev/orchestrator.py", line 41, in if_possible_parse_local_datetime df = utils.parse_local_datetime(df, dt_col=dt_cols[0], SP_col=sp_cols[0])
File "/Users/tomelder/opt/anaconda3/lib/python3.9/site-packages/ElexonDataPortal/dev/utils.py", line 135, in parse_local_datetime df_dates_SPs = dt_rng_to_SPs(start_date, end_date, freq=freq, tz=tz)
File "/Users/tomelder/opt/anaconda3/lib/python3.9/site-packages/ElexonDataPortal/dev/utils.py", line 119, in dt_rng_to_SPs df_dates_SPs = df_dates_SPs[start_date:end_date]
File "/Users/tomelder/opt/anaconda3/lib/python3.9/site-packages/pandas/core/frame.py", line 3735, in getitem indexer = self.index._convert_slice_indexer(key, kind="getitem")
File "/Users/tomelder/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 4132, in _convert_slice_indexer indexer = self.slice_indexer(start, stop, step)
File "/Users/tomelder/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/datetimes.py", line 636, in slice_indexer return Index.slice_indexer(self, start, end, step)
File "/Users/tomelder/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 6344, in slice_indexer start_slice, end_slice = self.slice_locs(start, end, step=step)
File "/Users/tomelder/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 6537, in slice_locs start_slice = self.get_slice_bound(start, "left")
File "/Users/tomelder/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 6452, in get_slice_bound label = self._maybe_cast_slice_bound(label, side)
File "/Users/tomelder/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexes/datetimes.py", line 597, in _maybe_cast_slice_bound self._data._assert_tzawareness_compat(label)
File "/Users/tomelder/opt/anaconda3/lib/python3.9/site-packages/pandas/core/arrays/datetimes.py", line 748, in _assert_tzawareness_compat raise TypeError(
TypeError: Cannot compare tz-naive and tz-aware datetime-like objects
I've got the same versions of panda and ElexonDataPortal installed.
what python version you using? OH i see 3.9
Looks like other people are having the same problem, - https://github.com/OSUKED/ElexonDataPortal/issues/23
maybe try wiht pandas 1.5.3
tried with 1.5.3 and it works! thanks for the help
/Users/tomelder/opt/anaconda3/lib/python3.9/site-packages/ElexonDataPortal/dev/utils.py:119: FutureWarning: Indexing a timezone-aware DatetimeIndex with a timezone-naive datetime is deprecated and will raise KeyError in a future version. Use a timezone-aware object instead. df_dates_SPs = df_dates_SPs[start_date:end_date]
came with this message.
yea, thats just a warning - nice it worked. Im sure ElexonDataPortal will sort that out when they get time
I keep getting the following error: TypeError: Cannot compare tz-naive and tz-aware datetime-like objects
PHYBMDATA: 100%|██████████| 95/95 [00:38<00:00, 2.48it/s] the data looks like it loads to completion, then it gives the error. I've tried updating my packages etc.
code: from ElexonDataPortal import api client = api.Client('api key')
start_date = '2020-01-01' end_date = '2020-01-02'
data from
WesterMost Rough
wind farmdf_PHYBMDATA = client.get_PHYBMDATA(start_date=start_date, end_date=end_date, BMUnitId='T_WTMSO-1') df_PHYBMDATA = df_PHYBMDATA[df_PHYBMDATA['recordType'] == 'PN'] df_PHYBMDATA = df_PHYBMDATA[['local_datetime','pnLevelFrom']]