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

+if clause for _query_imbalance in decorators #296

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions entsoe/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ def documents_wrapper(*args, **kwargs):
raise NoMatchingDataError

df = pd.concat(frames, sort=True)
# For same indices pick last valid value
if df.index.has_duplicates:
df = df.groupby(df.index).agg(deduplicate_documents_limited)
if func.__name__ != '_query_unavailability':
# For same indices pick last valid value
if df.index.has_duplicates:
df = df.groupby(df.index).agg(deduplicate_documents_limited)
return df
return documents_wrapper
return decorator
Expand Down Expand Up @@ -121,22 +122,23 @@ def year_wrapper(*args, start=None, end=None, **kwargs):
for _start, _end in blocks:
try:
frame = func(*args, start=_start, end=_end, **kwargs)
# Due to partial matching func may return data indexed by
# timestamps outside _start and _end. In order to avoid
# (unintentionally) repeating records, frames are truncated to
# left-open intervals (or closed interval in the case of the
# earliest block).
#
# If there are repeating records in a single frame (e.g. due
# to corrections) then the result will also have them.
if is_first_frame:
interval_mask = frame.index <= _end
else:
interval_mask = (
(frame.index <= _end)
& (frame.index > _start)
)
frame = frame.loc[interval_mask]
if func.__name__ != '_query_unavailability':
# Due to partial matching func may return data indexed by
# timestamps outside _start and _end. In order to avoid
# (unintentionally) repeating records, frames are truncated to
# left-open intervals (or closed interval in the case of the
# earliest block).
#
# If there are repeating records in a single frame (e.g. due
# to corrections) then the result will also have them.
if is_first_frame:
interval_mask = frame.index <= _end
else:
interval_mask = (
(frame.index <= _end)
& (frame.index > _start)
)
frame = frame.loc[interval_mask]
except NoMatchingDataError:
logger.debug(
f"NoMatchingDataError: between {_start} and {_end}"
Expand Down
4 changes: 3 additions & 1 deletion entsoe/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,9 @@ def _parse_aggregated_bids_timeseries(soup):

for dt, point in zip(tx, points):
df.loc[dt, 'Offered'] = float(point.find('quantity').text)
df.loc[dt, 'Activated'] = float(point.find('secondaryquantity').text)
activated = point.find('secondaryquantity')
if activated is not None:
df.loc[dt, 'Activated'] = float(activated.text)

mr_id = int(soup.find('mrid').text)
df.columns = pd.MultiIndex.from_product(
Expand Down