OSUKED/ElexonDataPortal

Cannot compare tz-naive and tz-aware datetime-like objects

matteodefelice opened this issue · 2 comments

Perhaps this is caused by pandas 2, but I haven't still found a solution:

start_date = pd.Timestamp('2023-06-01 00:00')
end_date   = pd.Timestamp('2023-06-01 01:00')
`
df_gen = client.get_B1620(start_date, end_date)

I get:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[c:\Users\matte\OneDrive\local\work\elexon\generation.py](file:///C:/Users/matte/OneDrive/local/work/elexon/generation.py) in line 5
      [11](file:///c%3A/Users/matte/OneDrive/local/work/elexon/generation.py?line=10) end_date   = pd.Timestamp('2023-06-01 01:00')
      [12](file:///c%3A/Users/matte/OneDrive/local/work/elexon/generation.py?line=11) # https://github.com/OSUKED/ElexonDataPortal#data-stream-descriptions
----> [13](file:///c%3A/Users/matte/OneDrive/local/work/elexon/generation.py?line=12) df_gen = client.get_B1620(start_date, end_date)
      [15](file:///c%3A/Users/matte/OneDrive/local/work/elexon/generation.py?line=14) # df_gen.to_csv('gen_202306.csv')
      [16](file:///c%3A/Users/matte/OneDrive/local/work/elexon/generation.py?line=15) df_gen.to_parquet('gen_202306.parquet')

File [c:\Users\matte\miniconda3\envs\pyfor\lib\site-packages\ElexonDataPortal\api.py:694](file:///C:/Users/matte/miniconda3/envs/pyfor/lib/site-packages/ElexonDataPortal/api.py:694), in Client.get_B1620(self, start_date, end_date)
    [681](file:///c%3A/Users/matte/miniconda3/envs/pyfor/lib/site-packages/ElexonDataPortal/api.py?line=680) def get_B1620(
    [682](file:///c%3A/Users/matte/miniconda3/envs/pyfor/lib/site-packages/ElexonDataPortal/api.py?line=681)     self,
    [683](file:///c%3A/Users/matte/miniconda3/envs/pyfor/lib/site-packages/ElexonDataPortal/api.py?line=682)     start_date: str = '2020-01-01', 
    [684](file:///c%3A/Users/matte/miniconda3/envs/pyfor/lib/site-packages/ElexonDataPortal/api.py?line=683)     end_date: str = '2020-01-01 1:30',
    [685](file:///c%3A/Users/matte/miniconda3/envs/pyfor/lib/site-packages/ElexonDataPortal/api.py?line=684) ):
    [686](file:///c%3A/Users/matte/miniconda3/envs/pyfor/lib/site-packages/ElexonDataPortal/api.py?line=685)     """
    [687](file:///c%3A/Users/matte/miniconda3/envs/pyfor/lib/site-packages/ElexonDataPortal/api.py?line=686)     Actual Aggregated Generation per Type
    [688](file:///c%3A/Users/matte/miniconda3/envs/pyfor/lib/site-packages/ElexonDataPortal/api.py?line=687)     
   (...)
    [691](file:///c%3A/Users/matte/miniconda3/envs/pyfor/lib/site-packages/ElexonDataPortal/api.py?line=690)         end_date (str)
    [692](file:///c%3A/Users/matte/miniconda3/envs/pyfor/lib/site-packages/ElexonDataPortal/api.py?line=691)     """
--> [694](file:///c%3A/Users/matte/miniconda3/envs/pyfor/lib/site-packages/ElexonDataPortal/api.py?line=693)     df = orchestrator.query_orchestrator(
    [695](file:///c%3A/Users/matte/miniconda3/envs/pyfor/lib/site-packages/ElexonDataPortal/api.py?line=694)         method = 'get_B1620',
    [696](file:///c%3A/Users/matte/miniconda3/envs/pyfor/lib/site-packages/ElexonDataPortal/api.py?line=695)         api_key = self.api_key,
    [697](file:///c%3A/Users/matte/miniconda3/envs/pyfor/lib/site-packages/ElexonDataPortal/api.py?line=696)         n_attempts = self.n_retry_attempts,
...
--> [748](file:///c%3A/Users/matte/miniconda3/envs/pyfor/lib/site-packages/pandas/core/arrays/datetimes.py?line=747)     raise TypeError(
    [749](file:///c%3A/Users/matte/miniconda3/envs/pyfor/lib/site-packages/pandas/core/arrays/datetimes.py?line=748)         "Cannot compare tz-naive and tz-aware datetime-like objects"
    [750](file:///c%3A/Users/matte/miniconda3/envs/pyfor/lib/site-packages/pandas/core/arrays/datetimes.py?line=749)     )

TypeError: Cannot compare tz-naive and tz-aware datetime-like objects


I'm having the same issue

damkad commented

This works for pandas==1.5.3