Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: '<=' not supported between instances of 'str' and 'Timestamp' #301

Closed
tdekelver-bd opened this issue Feb 5, 2024 · 1 comment

Comments

@tdekelver-bd
Copy link
Contributor

The code in V0.6.5 is not working anymore for query_installed_generation_capacity_per_unit. It gives an error due to line interval_mask = frame.index <= _end:

TypeError                                 Traceback (most recent call last)
Cell In[29], line 1
----> 1 df = client.query_installed_generation_capacity_per_unit('NL', start=start, end=end, psr_type=None)

File ~/.virtualenvs/EA_Vertex_ai/lib/python3.10/site-packages/entsoe/decorators.py:135, in year_limited.<locals>.year_wrapper(start, end, *args, **kwargs)
    125 if func.__name__ != '_query_unavailability':
    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:
--> 135         interval_mask = frame.index <= _end
    136     else:
    137         interval_mask = (
    138             (frame.index <= _end)
    139             & (frame.index > _start)
    140         )

File ~/.virtualenvs/EA_Vertex_ai/lib/python3.10/site-packages/pandas/core/ops/common.py:76, in _unpack_zerodim_and_defer.<locals>.new_method(self, other)
     72             return NotImplemented
     74 other = item_from_zerodim(other)
---> 76 return method(self, other)

File ~/.virtualenvs/EA_Vertex_ai/lib/python3.10/site-packages/pandas/core/arraylike.py:52, in OpsMixin.__le__(self, other)
     50 @unpack_zerodim_and_defer("__le__")
     51 def __le__(self, other):
---> 52     return self._cmp_method(other, operator.le)

File ~/.virtualenvs/EA_Vertex_ai/lib/python3.10/site-packages/pandas/core/indexes/base.py:7200, in Index._cmp_method(self, other, op)
   7196     result = op(self._values, other)
   7198 elif is_object_dtype(self.dtype) and not isinstance(self, ABCMultiIndex):
   7199     # don't pass MultiIndex
-> 7200     result = ops.comp_method_OBJECT_ARRAY(op, self._values, other)
   7202 else:
   7203     result = ops.comparison_op(self._values, other, op)

File ~/.virtualenvs/EA_Vertex_ai/lib/python3.10/site-packages/pandas/core/ops/array_ops.py:129, in comp_method_OBJECT_ARRAY(op, x, y)
    127     result = libops.vec_compare(x.ravel(), y.ravel(), op)
    128 else:
--> 129     result = libops.scalar_compare(x.ravel(), y, op)
    130 return result.reshape(x.shape)

File ops.pyx:107, in pandas._libs.ops.scalar_compare()

TypeError: '<=' not supported between instances of 'str' and 'Timestamp'

Code to reproduce:

from entsoe import EntsoePandasClient
import pandas as pd
client = EntsoePandasClient(api_key=api_key)
start = pd.Timestamp('2024-02-02 00:00:00+0100', tz='Europe/Brussels')
end = pd.Timestamp('2024-02-07 00:00:00+0100', tz='Europe/Brussels')
client.query_installed_generation_capacity_per_unit('NL', start=start, end=end, psr_type=None)
@fboerman
Copy link
Collaborator

fboerman commented Feb 5, 2024

oh dear that is a sideeffect of the fixed truncating code. will push out a fix, thanks for reporting this in such a clear manner with example snippit!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants