btd-python 0.1.2__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {btd_python-0.1.2 → btd_python-0.2.0}/PKG-INFO +5 -4
- btd_python-0.2.0/btd_client/source.py +493 -0
- {btd_python-0.1.2 → btd_python-0.2.0}/btd_python.egg-info/PKG-INFO +5 -4
- {btd_python-0.1.2 → btd_python-0.2.0}/btd_python.egg-info/SOURCES.txt +1 -0
- btd_python-0.2.0/btd_python.egg-info/requires.txt +2 -0
- {btd_python-0.1.2 → btd_python-0.2.0}/pyproject.toml +3 -4
- btd_python-0.1.2/btd_client/source.py +0 -213
- {btd_python-0.1.2 → btd_python-0.2.0}/btd_client/__init__.py +0 -0
- {btd_python-0.1.2 → btd_python-0.2.0}/btd_python.egg-info/dependency_links.txt +0 -0
- {btd_python-0.1.2 → btd_python-0.2.0}/btd_python.egg-info/top_level.txt +0 -0
- {btd_python-0.1.2 → btd_python-0.2.0}/setup.cfg +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: btd-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A python client for Baltic Transparency Data
|
|
5
|
-
Author
|
|
5
|
+
Author: Sarunas Jurgilas
|
|
6
6
|
License: MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/sarunasign/btd-python
|
|
8
8
|
Project-URL: Repository, https://github.com/sarunasign/btd-python
|
|
9
9
|
Requires-Python: >=3.7
|
|
10
|
-
|
|
10
|
+
Requires-Dist: requests
|
|
11
|
+
Requires-Dist: pandas
|
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
import io
|
|
2
|
+
import json
|
|
3
|
+
import zipfile
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
from typing import Dict, List, Optional
|
|
6
|
+
|
|
7
|
+
import pandas as pd
|
|
8
|
+
import requests
|
|
9
|
+
|
|
10
|
+
class BalticTransparencyClient:
|
|
11
|
+
"""
|
|
12
|
+
Form GET requests to Baltic Transparency dashboard. Retrieve relevant data, format it and return as Pandas DataFrame.
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
start_date : str
|
|
17
|
+
Starting date of data. Format 'yyyy-mm-ddTHH-mm'.
|
|
18
|
+
end_date : str
|
|
19
|
+
Last date of data. Format 'yyyy-mm-ddTHH-mm'.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(self, start_date: str, end_date: str):
|
|
23
|
+
# Validate format: 'YYYY-MM-DD'
|
|
24
|
+
try:
|
|
25
|
+
datetime.strptime(start_date, "%Y-%m-%d")
|
|
26
|
+
datetime.strptime(end_date, "%Y-%m-%d")
|
|
27
|
+
except ValueError:
|
|
28
|
+
raise ValueError("Dates must be in format 'YYYY-MM-DD'")
|
|
29
|
+
self.start_date = start_date + 'T00:00'
|
|
30
|
+
self.end_date = end_date + 'T00:00'
|
|
31
|
+
|
|
32
|
+
API_BASE_URL = 'https://api-baltic.transparency-dashboard.eu/api/v1'
|
|
33
|
+
|
|
34
|
+
def _request(self, endpoint: str, api_id: str) -> requests.Response:
|
|
35
|
+
"""Send API request with GET method."""
|
|
36
|
+
params = {
|
|
37
|
+
"id": api_id,
|
|
38
|
+
"start_date": self.start_date,
|
|
39
|
+
"end_date": self.end_date,
|
|
40
|
+
"output_time_zone": 'EET',
|
|
41
|
+
"output_format": 'json'
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
response = requests.get(f"{self.API_BASE_URL}/{endpoint}", params=params)
|
|
45
|
+
if response.status_code == 200:
|
|
46
|
+
return response
|
|
47
|
+
else:
|
|
48
|
+
raise TimeoutError(f"Could not retrieve data. API status code {response.status_code}")
|
|
49
|
+
|
|
50
|
+
def _get_data(self, api_id: str) -> str:
|
|
51
|
+
"""Retrieve a single report via the /export endpoint."""
|
|
52
|
+
return self._request('export', api_id).text
|
|
53
|
+
|
|
54
|
+
def _get_multiple_data(self, api_ids: List[str]) -> Dict[str, dict]:
|
|
55
|
+
"""Retrieve several reports via the /export-multiple endpoint (returned as a zip of JSON files)."""
|
|
56
|
+
response = self._request('export-multiple', ','.join(api_ids))
|
|
57
|
+
reports = {}
|
|
58
|
+
with zipfile.ZipFile(io.BytesIO(response.content)) as archive:
|
|
59
|
+
for name in archive.namelist():
|
|
60
|
+
report = json.loads(archive.read(name))
|
|
61
|
+
reports[report['id']] = report
|
|
62
|
+
return reports
|
|
63
|
+
|
|
64
|
+
@staticmethod
|
|
65
|
+
def _infer_levels(columns_info: list) -> int:
|
|
66
|
+
"""Pick the smallest number of group levels that yields unique column names."""
|
|
67
|
+
if any(col.get('group_level_1') for col in columns_info):
|
|
68
|
+
return 3
|
|
69
|
+
groups = [col['group_level_0'] for col in columns_info]
|
|
70
|
+
if all(col.get('label') is None for col in columns_info) or len(set(groups)) == len(groups):
|
|
71
|
+
return 1
|
|
72
|
+
return 2
|
|
73
|
+
|
|
74
|
+
def _unravel_response(self, response: str, levels: int = 1) -> pd.DataFrame:
|
|
75
|
+
"""
|
|
76
|
+
Parse and convert the JSON response to a pandas DataFrame.
|
|
77
|
+
|
|
78
|
+
Parameters
|
|
79
|
+
----------
|
|
80
|
+
response : str
|
|
81
|
+
JSON-formatted response string.
|
|
82
|
+
levels : int
|
|
83
|
+
Number of group levels to use in column names (1, 2, or 3).
|
|
84
|
+
|
|
85
|
+
Returns
|
|
86
|
+
-------
|
|
87
|
+
pd.DataFrame
|
|
88
|
+
Formatted time-indexed DataFrame.
|
|
89
|
+
"""
|
|
90
|
+
response_json = json.loads(response)
|
|
91
|
+
return self._data_to_df(response_json['data'], levels)
|
|
92
|
+
|
|
93
|
+
def _data_to_df(self, data: dict, levels: int = 1) -> pd.DataFrame:
|
|
94
|
+
"""Convert the 'data' object of a report to a time-indexed DataFrame."""
|
|
95
|
+
# Generate column names based on level depth
|
|
96
|
+
columns_info = data['columns']
|
|
97
|
+
if levels == 3:
|
|
98
|
+
columns_map = {
|
|
99
|
+
col['index']: f"{col['group_level_0']} {col['group_level_1']} {col['label']}" for col in columns_info
|
|
100
|
+
}
|
|
101
|
+
elif levels == 2:
|
|
102
|
+
columns_map = {
|
|
103
|
+
col['index']: f"{col['group_level_0']} {col['label']}" for col in columns_info
|
|
104
|
+
}
|
|
105
|
+
else: # levels == 1
|
|
106
|
+
columns_map = {
|
|
107
|
+
col['index']: col['group_level_0'] for col in columns_info
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
# Build records
|
|
111
|
+
data_records = []
|
|
112
|
+
for entry in data['timeseries']:
|
|
113
|
+
record = {'datetime': entry['from']}
|
|
114
|
+
for idx, value in enumerate(entry['values']):
|
|
115
|
+
if idx in columns_map:
|
|
116
|
+
record[columns_map[idx]] = value
|
|
117
|
+
data_records.append(record)
|
|
118
|
+
|
|
119
|
+
# Create DataFrame
|
|
120
|
+
df = pd.DataFrame(data_records, columns=['datetime', *dict.fromkeys(columns_map.values())])
|
|
121
|
+
df['datetime'] = pd.to_datetime(df['datetime'], utc=True).dt.tz_convert('Europe/Vilnius').dt.tz_localize(None)
|
|
122
|
+
df.set_index('datetime', inplace=True)
|
|
123
|
+
|
|
124
|
+
return df
|
|
125
|
+
|
|
126
|
+
def multiple_reports_df(self, api_ids: List[str], levels: Optional[Dict[str, int]] = None) -> Dict[str, pd.DataFrame]:
|
|
127
|
+
"""
|
|
128
|
+
Get several reports in one request (/export-multiple endpoint).
|
|
129
|
+
|
|
130
|
+
Parameters
|
|
131
|
+
----------
|
|
132
|
+
api_ids : list of str
|
|
133
|
+
Report IDs, e.g. ['imbalance_prices', 'activations_afrr'].
|
|
134
|
+
levels : dict, optional
|
|
135
|
+
Mapping of report ID to number of group levels used in column names (1, 2, or 3).
|
|
136
|
+
Levels are inferred from the report columns for IDs not in the mapping.
|
|
137
|
+
|
|
138
|
+
Returns
|
|
139
|
+
-------
|
|
140
|
+
dict of str to pd.DataFrame
|
|
141
|
+
DataFrame per report ID.
|
|
142
|
+
"""
|
|
143
|
+
levels = levels or {}
|
|
144
|
+
reports = self._get_multiple_data(api_ids)
|
|
145
|
+
return {
|
|
146
|
+
api_id: self._data_to_df(data, levels.get(api_id, self._infer_levels(data['columns'])))
|
|
147
|
+
for api_id, data in reports.items()
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
def procured_balancing_reserve_prices_df(self) -> pd.DataFrame:
|
|
151
|
+
"""Get df of TSO procured balancing reserve prices (EUR/MW)."""
|
|
152
|
+
response = self._get_data(api_id='price_procured_reserves')
|
|
153
|
+
return self._unravel_response(response, levels=3)
|
|
154
|
+
|
|
155
|
+
def procured_balancing_reserve_volumes_df(self) -> pd.DataFrame:
|
|
156
|
+
"""Get df of TSO procured balancing reserve volumes (MW)."""
|
|
157
|
+
response = self._get_data(api_id='procured_reserves')
|
|
158
|
+
return self._unravel_response(response, levels=3)
|
|
159
|
+
|
|
160
|
+
def cbmp_df(self) -> pd.DataFrame:
|
|
161
|
+
"""Get df of cross border marginal prices (EUR/MWh)."""
|
|
162
|
+
response = self._get_data(api_id='cross_border_marginal_price')
|
|
163
|
+
return self._unravel_response(response, levels=3)
|
|
164
|
+
|
|
165
|
+
def afrr_bid_prices_df(self) -> pd.DataFrame:
|
|
166
|
+
"""Get df of offered min/max afrr prices."""
|
|
167
|
+
response = self._get_data(api_id='afrr_bid_prices')
|
|
168
|
+
return self._unravel_response(response, levels=3)
|
|
169
|
+
|
|
170
|
+
def da_mfrr_bid_prices_df(self) -> pd.DataFrame:
|
|
171
|
+
"""Get df of offered min/max direct mfrr prices."""
|
|
172
|
+
response = self._get_data(api_id='da_mfrr_bid_prices')
|
|
173
|
+
return self._unravel_response(response, levels=3)
|
|
174
|
+
|
|
175
|
+
def sa_mfrr_bid_prices_df(self) -> pd.DataFrame:
|
|
176
|
+
"""Get df of offered min/max scheduled mfrr prices."""
|
|
177
|
+
response = self._get_data(api_id='sa_mfrr_bid_prices')
|
|
178
|
+
return self._unravel_response(response, levels=3)
|
|
179
|
+
|
|
180
|
+
def da_mfrr_bid_volumes_df(self) -> pd.DataFrame:
|
|
181
|
+
"""Get df of offered direct mfrr volumes."""
|
|
182
|
+
response = self._get_data(api_id='da_mfrr_bid_volumes')
|
|
183
|
+
return self._unravel_response(response, levels=2)
|
|
184
|
+
|
|
185
|
+
def sa_mfrr_bid_volumes_df(self) -> pd.DataFrame:
|
|
186
|
+
"""Get df of offered scheduled mfrr volumes."""
|
|
187
|
+
response = self._get_data(api_id='sa_mfrr_bid_volumes')
|
|
188
|
+
return self._unravel_response(response, levels=2)
|
|
189
|
+
|
|
190
|
+
def imbalance_volumes_df(self) -> pd.DataFrame:
|
|
191
|
+
"""Get df of imbalance volumes for each country (MWh)."""
|
|
192
|
+
response = self._get_data(api_id='imbalance_volumes_v2')
|
|
193
|
+
return self._unravel_response(response, levels=1)
|
|
194
|
+
|
|
195
|
+
def activated_afrr_volumes_df(self) -> pd.DataFrame:
|
|
196
|
+
"""Get df of activated afrr energy (MWh)"""
|
|
197
|
+
response = self._get_data(api_id='activations_afrr')
|
|
198
|
+
return self._unravel_response(response, levels=2)
|
|
199
|
+
|
|
200
|
+
def balancing_energy_ref_prices_df(self) -> pd.DataFrame:
|
|
201
|
+
"""Get df of balancing energy reference prices (EUR/MWh)."""
|
|
202
|
+
response = self._get_data(api_id='balancing_energy_prices')
|
|
203
|
+
return self._unravel_response(response, levels=2)
|
|
204
|
+
|
|
205
|
+
def current_balancing_state_df(self) -> pd.DataFrame:
|
|
206
|
+
"""Get df of imbalance volumes (MW) for each country with 1 minute resolution."""
|
|
207
|
+
response = self._get_data(api_id='current_balancing_state_v2')
|
|
208
|
+
return self._unravel_response(response, levels=1)
|
|
209
|
+
|
|
210
|
+
def direction_of_system_balancing_df(self) -> pd.DataFrame:
|
|
211
|
+
"""Get df of the directions of system balancing (-1/+1)."""
|
|
212
|
+
response = self._get_data(api_id='direction_of_balancing_v2')
|
|
213
|
+
return self._unravel_response(response, levels=1)
|
|
214
|
+
|
|
215
|
+
def imbalance_prices_df(self) -> pd.DataFrame:
|
|
216
|
+
"""Get df of imabalnce prices calculated by each Baltics TSO."""
|
|
217
|
+
response = self._get_data(api_id='imbalance_prices')
|
|
218
|
+
return self._unravel_response(response, levels=1)
|
|
219
|
+
|
|
220
|
+
def neutrality_component_df(self) -> pd.DataFrame:
|
|
221
|
+
"""Get df the neutrality components."""
|
|
222
|
+
response = self._get_data(api_id='neutrality_component')
|
|
223
|
+
return self._unravel_response(response, levels=1)
|
|
224
|
+
|
|
225
|
+
def local_marginal_prices_df(self) -> pd.DataFrame:
|
|
226
|
+
"""Get df of local marginal mFRR prices (EUR/MWh). Kept for backwards compatibility,
|
|
227
|
+
the 'local_marginal_price' report was replaced by 'local_marginal_price_mfrr'."""
|
|
228
|
+
return self.local_marginal_mfrr_prices_df()
|
|
229
|
+
|
|
230
|
+
def local_marginal_mfrr_prices_df(self) -> pd.DataFrame:
|
|
231
|
+
"""Get df of local marginal mFRR prices (EUR/MWh)."""
|
|
232
|
+
response = self._get_data(api_id='local_marginal_price_mfrr')
|
|
233
|
+
return self._unravel_response(response, levels=2)
|
|
234
|
+
|
|
235
|
+
def local_marginal_afrr_prices_df(self) -> pd.DataFrame:
|
|
236
|
+
"""Get df of clearing (marginal) aFRR prices (EUR/MWh)."""
|
|
237
|
+
response = self._get_data(api_id='local_marginal_price_afrr')
|
|
238
|
+
return self._unravel_response(response, levels=2)
|
|
239
|
+
|
|
240
|
+
def normal_activations_da_volumes_df(self) -> pd.DataFrame:
|
|
241
|
+
"""Get df of total direct mFRR energy activation volumes."""
|
|
242
|
+
response = self._get_data(api_id='normal_activations_da_mfrr')
|
|
243
|
+
return self._unravel_response(response, levels=2)
|
|
244
|
+
|
|
245
|
+
def normal_activations_sa_volumes_df(self) -> pd.DataFrame:
|
|
246
|
+
"""Get df of total scheduled mFRR energy activation volumes."""
|
|
247
|
+
response = self._get_data(api_id='normal_activations_sa_mfrr')
|
|
248
|
+
return self._unravel_response(response, levels=2)
|
|
249
|
+
|
|
250
|
+
def normal_activations_total_volumes_df(self) -> pd.DataFrame:
|
|
251
|
+
"""Get df of total normal balancing energy activated volumes."""
|
|
252
|
+
response = self._get_data(api_id='normal_activations_total')
|
|
253
|
+
return self._unravel_response(response, levels=2)
|
|
254
|
+
|
|
255
|
+
def afrr_bid_volumes_df(self) -> pd.DataFrame:
|
|
256
|
+
"""Get df of offered afrr bid volumes (MW)."""
|
|
257
|
+
response = self._get_data(api_id='volumes_afrr')
|
|
258
|
+
return self._unravel_response(response, levels=2)
|
|
259
|
+
|
|
260
|
+
def unavailable_afrr_bid_volumes_df(self) -> pd.DataFrame:
|
|
261
|
+
"""Get df of unavailable afrr bid volumes (MW)."""
|
|
262
|
+
response = self._get_data(api_id='unavailable_afrr_bid_volumes')
|
|
263
|
+
return self._unravel_response(response, levels=2)
|
|
264
|
+
|
|
265
|
+
def afrr_satisfied_demand_prices_df(self) -> pd.DataFrame:
|
|
266
|
+
"""Get df of afrr satisfied demand prices (EUR/MWh)."""
|
|
267
|
+
response = self._get_data(api_id='afrr_satisfied_demand_price')
|
|
268
|
+
return self._unravel_response(response, levels=2)
|
|
269
|
+
|
|
270
|
+
def satisfied_demand_afrr_df(self) -> pd.DataFrame:
|
|
271
|
+
"""Get df of total satisfied demand for balancing purposes from afrr (MWh)."""
|
|
272
|
+
response = self._get_data(api_id='satisfied_demand_afrr')
|
|
273
|
+
return self._unravel_response(response, levels=2)
|
|
274
|
+
|
|
275
|
+
def netted_exchanged_afrr_volumes_df(self) -> pd.DataFrame:
|
|
276
|
+
"""Get df of netted and exchanged afrr volumes (MWh)."""
|
|
277
|
+
response = self._get_data(api_id='netted_exchanged_volumes_afrr')
|
|
278
|
+
return self._unravel_response(response, levels=1)
|
|
279
|
+
|
|
280
|
+
def mfrr_bid_prices_df(self) -> pd.DataFrame:
|
|
281
|
+
"""Get df of offered min/max mfrr prices (EUR/MWh)."""
|
|
282
|
+
response = self._get_data(api_id='mfrr_bid_prices')
|
|
283
|
+
return self._unravel_response(response, levels=3)
|
|
284
|
+
|
|
285
|
+
def mfrr_bid_volumes_df(self) -> pd.DataFrame:
|
|
286
|
+
"""Get df of offered mfrr volumes (MW), 1 hour resolution."""
|
|
287
|
+
response = self._get_data(api_id='mfrr_bid_volumes')
|
|
288
|
+
return self._unravel_response(response, levels=2)
|
|
289
|
+
|
|
290
|
+
def er_mfrr_bid_prices_df(self) -> pd.DataFrame:
|
|
291
|
+
"""Get df of offered min/max ER mfrr prices (EUR/MWh)."""
|
|
292
|
+
response = self._get_data(api_id='er_mfrr_bid_prices')
|
|
293
|
+
return self._unravel_response(response, levels=3)
|
|
294
|
+
|
|
295
|
+
def er_mfrr_bid_volumes_df(self) -> pd.DataFrame:
|
|
296
|
+
"""Get df of offered ER mfrr volumes (MW)."""
|
|
297
|
+
response = self._get_data(api_id='er_mfrr_bid_volumes')
|
|
298
|
+
return self._unravel_response(response, levels=2)
|
|
299
|
+
|
|
300
|
+
def local_mfrr_er_bid_volumes_df(self) -> pd.DataFrame:
|
|
301
|
+
"""Get df of offered local mfrr (ER) volumes (MW)."""
|
|
302
|
+
response = self._get_data(api_id='local_mfrr_er_bid_volumes')
|
|
303
|
+
return self._unravel_response(response, levels=2)
|
|
304
|
+
|
|
305
|
+
def unavailable_mfrr_bid_volumes_df(self) -> pd.DataFrame:
|
|
306
|
+
"""Get df of unavailable mfrr bid volumes (MW)."""
|
|
307
|
+
response = self._get_data(api_id='unavailable_mfrr_bid_volumes_v2')
|
|
308
|
+
return self._unravel_response(response, levels=2)
|
|
309
|
+
|
|
310
|
+
def unavailable_mfrr_bid_volumes_legacy_df(self) -> pd.DataFrame:
|
|
311
|
+
"""Get df of unavailable mfrr bid volumes (MW), legacy report."""
|
|
312
|
+
response = self._get_data(api_id='unavailable_mfrr_bid_volumes')
|
|
313
|
+
return self._unravel_response(response, levels=2)
|
|
314
|
+
|
|
315
|
+
def mfrr_satisfied_demand_prices_df(self) -> pd.DataFrame:
|
|
316
|
+
"""Get df of mfrr satisfied demand prices (EUR/MWh)."""
|
|
317
|
+
response = self._get_data(api_id='mfrr_satisfied_demand_price')
|
|
318
|
+
return self._unravel_response(response, levels=2)
|
|
319
|
+
|
|
320
|
+
def netted_exchanged_mfrr_volumes_df(self) -> pd.DataFrame:
|
|
321
|
+
"""Get df of netted and exchanged mfrr volumes (MWh)."""
|
|
322
|
+
response = self._get_data(api_id='netted_exchanged_volumes')
|
|
323
|
+
return self._unravel_response(response, levels=1)
|
|
324
|
+
|
|
325
|
+
def normal_activations_er_volumes_df(self) -> pd.DataFrame:
|
|
326
|
+
"""Get df of ER mFRR normal activation volumes (MWh)."""
|
|
327
|
+
response = self._get_data(api_id='normal_activations_er_mfrr')
|
|
328
|
+
return self._unravel_response(response, levels=2)
|
|
329
|
+
|
|
330
|
+
def normal_activations_local_volumes_df(self) -> pd.DataFrame:
|
|
331
|
+
"""Get df of local mFRR normal activation volumes (MWh)."""
|
|
332
|
+
response = self._get_data(api_id='normal_activations_local_mfrr')
|
|
333
|
+
return self._unravel_response(response, levels=2)
|
|
334
|
+
|
|
335
|
+
def normal_activations_mfrr_volumes_df(self) -> pd.DataFrame:
|
|
336
|
+
"""Get df of mFRR normal activation volumes (MWh)."""
|
|
337
|
+
response = self._get_data(api_id='normal_activations_mfrr')
|
|
338
|
+
return self._unravel_response(response, levels=2)
|
|
339
|
+
|
|
340
|
+
def special_activations_total_volumes_df(self) -> pd.DataFrame:
|
|
341
|
+
"""Get df of total special activation volumes (MWh)."""
|
|
342
|
+
response = self._get_data(api_id='special_activations_total')
|
|
343
|
+
return self._unravel_response(response, levels=2)
|
|
344
|
+
|
|
345
|
+
def special_activations_mfrr_volumes_df(self) -> pd.DataFrame:
|
|
346
|
+
"""Get df of total mFRR special activation volumes (MWh)."""
|
|
347
|
+
response = self._get_data(api_id='special_activations_total_mfrr')
|
|
348
|
+
return self._unravel_response(response, levels=2)
|
|
349
|
+
|
|
350
|
+
def system_services_volumes_df(self) -> pd.DataFrame:
|
|
351
|
+
"""Get df of balancing energy volumes activated for system services (MWh)."""
|
|
352
|
+
response = self._get_data(api_id='system_services')
|
|
353
|
+
return self._unravel_response(response, levels=2)
|
|
354
|
+
|
|
355
|
+
def countertrade_volumes_df(self) -> pd.DataFrame:
|
|
356
|
+
"""Get df of balancing energy volumes activated for countertrade (MWh)."""
|
|
357
|
+
response = self._get_data(api_id='countertrade')
|
|
358
|
+
return self._unravel_response(response, levels=2)
|
|
359
|
+
|
|
360
|
+
def baltic_tso_tso_exchange_df(self) -> pd.DataFrame:
|
|
361
|
+
"""Get df of Baltic TSO-TSO exchanged volumes (MWh)."""
|
|
362
|
+
response = self._get_data(api_id='baltic_tso_tso_exchange')
|
|
363
|
+
return self._unravel_response(response, levels=1)
|
|
364
|
+
|
|
365
|
+
def total_satisfied_demand_from_nonbaltic_tsos_df(self) -> pd.DataFrame:
|
|
366
|
+
"""Get df of total satisfied demand from non-Baltic TSOs (MWh)."""
|
|
367
|
+
response = self._get_data(api_id='total_satisfied_demand_from_nonbaltic_tsos')
|
|
368
|
+
return self._unravel_response(response, levels=2)
|
|
369
|
+
|
|
370
|
+
def procured_balancing_reserve_prices_legacy_df(self) -> pd.DataFrame:
|
|
371
|
+
"""Get df of TSO procured balancing reserve prices (EUR/MW/h), 1 hour resolution legacy report."""
|
|
372
|
+
response = self._get_data(api_id='price_procured_reserves_legacy')
|
|
373
|
+
return self._unravel_response(response, levels=3)
|
|
374
|
+
|
|
375
|
+
def procured_balancing_reserve_volumes_legacy_df(self) -> pd.DataFrame:
|
|
376
|
+
"""Get df of TSO procured balancing reserve volumes (MW), 1 hour resolution legacy report."""
|
|
377
|
+
response = self._get_data(api_id='procured_reserves_legacy')
|
|
378
|
+
return self._unravel_response(response, levels=3)
|
|
379
|
+
|
|
380
|
+
def balancing_reserves_demand_df(self) -> pd.DataFrame:
|
|
381
|
+
"""Get df of demand for balancing reserves (MW)."""
|
|
382
|
+
response = self._get_data(api_id='reserves_demand')
|
|
383
|
+
return self._unravel_response(response, levels=3)
|
|
384
|
+
|
|
385
|
+
def balancing_reserves_demand_legacy_df(self) -> pd.DataFrame:
|
|
386
|
+
"""Get df of demand for balancing reserves (MW), 1 hour resolution legacy report."""
|
|
387
|
+
response = self._get_data(api_id='reserves_demand_legacy')
|
|
388
|
+
return self._unravel_response(response, levels=3)
|
|
389
|
+
|
|
390
|
+
def increased_demands_df(self) -> pd.DataFrame:
|
|
391
|
+
"""Get df of increased demands for balancing reserves (MW)."""
|
|
392
|
+
response = self._get_data(api_id='increased_demands')
|
|
393
|
+
return self._unravel_response(response, levels=3)
|
|
394
|
+
|
|
395
|
+
def fcr_reserve_bid_prices_df(self) -> pd.DataFrame:
|
|
396
|
+
"""Get df of offered min/max FCR reserve bid prices (EUR/MWh)."""
|
|
397
|
+
response = self._get_data(api_id='fcr_reserve_bid_price')
|
|
398
|
+
return self._unravel_response(response, levels=3)
|
|
399
|
+
|
|
400
|
+
def afrr_reserve_bid_prices_df(self) -> pd.DataFrame:
|
|
401
|
+
"""Get df of offered min/max aFRR reserve bid prices (EUR/MWh)."""
|
|
402
|
+
response = self._get_data(api_id='price_afrr_reserve_bids')
|
|
403
|
+
return self._unravel_response(response, levels=3)
|
|
404
|
+
|
|
405
|
+
def mfrr_reserve_bid_prices_df(self) -> pd.DataFrame:
|
|
406
|
+
"""Get df of offered min/max mFRR reserve bid prices (EUR/MWh)."""
|
|
407
|
+
response = self._get_data(api_id='price_mfrr_reserve_bids')
|
|
408
|
+
return self._unravel_response(response, levels=3)
|
|
409
|
+
|
|
410
|
+
def reserve_bid_volumes_df(self) -> pd.DataFrame:
|
|
411
|
+
"""Get df of offered reserve bid volumes (MW)."""
|
|
412
|
+
response = self._get_data(api_id='volume_of_reserve_bids')
|
|
413
|
+
return self._unravel_response(response, levels=3)
|
|
414
|
+
|
|
415
|
+
def back_up_reserve_bid_volumes_df(self) -> pd.DataFrame:
|
|
416
|
+
"""Get df of offered back-up reserve bid volumes (MW)."""
|
|
417
|
+
response = self._get_data(api_id='volume_of_back_up_reserve_bids')
|
|
418
|
+
return self._unravel_response(response, levels=3)
|
|
419
|
+
|
|
420
|
+
def demand_reduction_reserve_bid_volumes_df(self) -> pd.DataFrame:
|
|
421
|
+
"""Get df of offered demand reduction reserve bid volumes (MW)."""
|
|
422
|
+
response = self._get_data(api_id='volume_of_demand_reduction_reserve_bids')
|
|
423
|
+
return self._unravel_response(response, levels=3)
|
|
424
|
+
|
|
425
|
+
def allocated_cb_capacity_df(self) -> pd.DataFrame:
|
|
426
|
+
"""Get df of allocated cross-border capacity for balancing reserves (MW)."""
|
|
427
|
+
response = self._get_data(api_id='allocated_cb_capacity')
|
|
428
|
+
return self._unravel_response(response, levels=2)
|
|
429
|
+
|
|
430
|
+
def allocated_cb_capacity_legacy_df(self) -> pd.DataFrame:
|
|
431
|
+
"""Get df of allocated cross-border capacity for balancing reserves (MW), 1 hour resolution legacy report."""
|
|
432
|
+
response = self._get_data(api_id='allocated_cb_capacity_legacy')
|
|
433
|
+
return self._unravel_response(response, levels=2)
|
|
434
|
+
|
|
435
|
+
def allocated_capacity_limits_df(self) -> pd.DataFrame:
|
|
436
|
+
"""Get df of allocated capacity limits (%)."""
|
|
437
|
+
response = self._get_data(api_id='allocated_capacity_limit')
|
|
438
|
+
return self._unravel_response(response, levels=2)
|
|
439
|
+
|
|
440
|
+
def cross_border_capacity_limits_df(self) -> pd.DataFrame:
|
|
441
|
+
"""Get df of cross-border capacity limits (MW)."""
|
|
442
|
+
response = self._get_data(api_id='cross_border_capacity_limits_v2')
|
|
443
|
+
return self._unravel_response(response, levels=2)
|
|
444
|
+
|
|
445
|
+
def cross_zonal_capacities_df(self) -> pd.DataFrame:
|
|
446
|
+
"""Get df of cross-zonal capacities within the balancing timeframe (MW)."""
|
|
447
|
+
response = self._get_data(api_id='cross_zonal_capacities')
|
|
448
|
+
return self._unravel_response(response, levels=2)
|
|
449
|
+
|
|
450
|
+
def applied_mark_up_df(self) -> pd.DataFrame:
|
|
451
|
+
"""Get df of applied mark-ups (EUR/MWh)."""
|
|
452
|
+
response = self._get_data(api_id='applied_mark_up')
|
|
453
|
+
return self._unravel_response(response, levels=1)
|
|
454
|
+
|
|
455
|
+
def imbalance_volumes_legacy_df(self) -> pd.DataFrame:
|
|
456
|
+
"""Get df of imbalance volumes (MWh), legacy report incl. Baltics total."""
|
|
457
|
+
response = self._get_data(api_id='imbalance_volumes')
|
|
458
|
+
return self._unravel_response(response, levels=1)
|
|
459
|
+
|
|
460
|
+
def current_balancing_state_legacy_df(self) -> pd.DataFrame:
|
|
461
|
+
"""Get df of imbalance volumes (MW) with 1 minute resolution, legacy report incl. Baltics total."""
|
|
462
|
+
response = self._get_data(api_id='current_balancing_state')
|
|
463
|
+
return self._unravel_response(response, levels=1)
|
|
464
|
+
|
|
465
|
+
def direction_of_system_balancing_legacy_df(self) -> pd.DataFrame:
|
|
466
|
+
"""Get df of the Baltics direction of system balancing (-1/+1), legacy report."""
|
|
467
|
+
response = self._get_data(api_id='direction_of_balancing')
|
|
468
|
+
return self._unravel_response(response, levels=1)
|
|
469
|
+
|
|
470
|
+
def neutrality_component_legacy_df(self) -> pd.DataFrame:
|
|
471
|
+
"""Get df of the Baltics neutrality component (EUR/MWh), legacy report."""
|
|
472
|
+
response = self._get_data(api_id='neutrality')
|
|
473
|
+
return self._unravel_response(response, levels=1)
|
|
474
|
+
|
|
475
|
+
def total_satisfied_demand_for_balancing_purposes_df(self) -> pd.DataFrame:
|
|
476
|
+
"""Get df total satisfied demands for balancing purposes (MWh)."""
|
|
477
|
+
response = self._get_data(api_id='total_satisfied_demand_for_balancing_purposes')
|
|
478
|
+
df = self._unravel_response(response, levels=2)
|
|
479
|
+
return df
|
|
480
|
+
|
|
481
|
+
def total_satisfied_demand_for_balancing_purposes_mod_df(self) -> pd.DataFrame:
|
|
482
|
+
"""Get df total satisfied demands for balancing purposes. Convertet to MW and
|
|
483
|
+
total Baltics demand computed and returned."""
|
|
484
|
+
response = self._get_data(api_id='total_satisfied_demand_for_balancing_purposes')
|
|
485
|
+
df = self._unravel_response(response, levels=2)
|
|
486
|
+
|
|
487
|
+
# Apply processing logic
|
|
488
|
+
downward_columns = [col for col in df.columns if "Downward" in col]
|
|
489
|
+
df[downward_columns] = df[downward_columns].apply(pd.to_numeric, errors='coerce') * -1
|
|
490
|
+
df = df.dropna()
|
|
491
|
+
df['Baltics_net'] = df.sum(axis=1)
|
|
492
|
+
df *= 4
|
|
493
|
+
return df
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: btd-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A python client for Baltic Transparency Data
|
|
5
|
-
Author
|
|
5
|
+
Author: Sarunas Jurgilas
|
|
6
6
|
License: MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/sarunasign/btd-python
|
|
8
8
|
Project-URL: Repository, https://github.com/sarunasign/btd-python
|
|
9
9
|
Requires-Python: >=3.7
|
|
10
|
-
|
|
10
|
+
Requires-Dist: requests
|
|
11
|
+
Requires-Dist: pandas
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "btd-python" # This will be your pip install name
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.2.0"
|
|
4
4
|
description = "A python client for Baltic Transparency Data"
|
|
5
5
|
authors = [
|
|
6
|
-
{ name = "Sarunas Jurgilas"
|
|
6
|
+
{ name = "Sarunas Jurgilas" }
|
|
7
7
|
]
|
|
8
|
-
readme = "README.md"
|
|
9
8
|
license = { text = "MIT" }
|
|
10
9
|
requires-python = ">=3.7"
|
|
11
|
-
dependencies = [] # Add any dependencies here, like requests, etc.
|
|
10
|
+
dependencies = ["requests", "pandas"] # Add any dependencies here, like requests, etc.
|
|
12
11
|
|
|
13
12
|
[project.urls]
|
|
14
13
|
Homepage = "https://github.com/sarunasign/btd-python"
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import requests
|
|
2
|
-
import json
|
|
3
|
-
import pandas as pd
|
|
4
|
-
from datetime import datetime
|
|
5
|
-
|
|
6
|
-
class BalticTransparencyClient:
|
|
7
|
-
"""
|
|
8
|
-
Form GET requests to Baltic Transparency dashboard. Retrieve relevant data, format it and return as Pandas DataFrame.
|
|
9
|
-
|
|
10
|
-
Parameters
|
|
11
|
-
----------
|
|
12
|
-
start_date : str
|
|
13
|
-
Starting date of data. Format 'yyyy-mm-ddTHH-mm'.
|
|
14
|
-
end_date : str
|
|
15
|
-
Last date of data. Format 'yyyy-mm-ddTHH-mm'.
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
def __init__(self, start_date: str, end_date: str):
|
|
19
|
-
# Validate format: 'YYYY-MM-DD'
|
|
20
|
-
try:
|
|
21
|
-
datetime.strptime(start_date, "%Y-%m-%d")
|
|
22
|
-
datetime.strptime(end_date, "%Y-%m-%d")
|
|
23
|
-
except ValueError:
|
|
24
|
-
raise ValueError("Dates must be in format 'YYYY-MM-DD'")
|
|
25
|
-
self.start_date = start_date + 'T00:00'
|
|
26
|
-
self.end_date = end_date + 'T00:00'
|
|
27
|
-
|
|
28
|
-
def _get_data(self, api_id: str) -> str:
|
|
29
|
-
"""Send API request with GET method."""
|
|
30
|
-
api_url = 'https://api-baltic.transparency-dashboard.eu/api/v1/export'
|
|
31
|
-
|
|
32
|
-
params = {
|
|
33
|
-
"id": api_id,
|
|
34
|
-
"start_date": self.start_date,
|
|
35
|
-
"end_date": self.end_date,
|
|
36
|
-
"output_time_zone": 'EET',
|
|
37
|
-
"output_format": 'json'
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
response = requests.get(api_url, params=params)
|
|
41
|
-
if response.status_code == 200:
|
|
42
|
-
return response.text
|
|
43
|
-
else:
|
|
44
|
-
raise TimeoutError(f"Could not retrieve data. API status code {response.status_code}")
|
|
45
|
-
|
|
46
|
-
def _unravel_response(self, response: str, levels: int = 1) -> pd.DataFrame:
|
|
47
|
-
"""
|
|
48
|
-
Parse and convert the JSON response to a pandas DataFrame.
|
|
49
|
-
|
|
50
|
-
Parameters
|
|
51
|
-
----------
|
|
52
|
-
response : str
|
|
53
|
-
JSON-formatted response string.
|
|
54
|
-
levels : int
|
|
55
|
-
Number of group levels to use in column names (1, 2, or 3).
|
|
56
|
-
|
|
57
|
-
Returns
|
|
58
|
-
-------
|
|
59
|
-
pd.DataFrame
|
|
60
|
-
Formatted time-indexed DataFrame.
|
|
61
|
-
"""
|
|
62
|
-
response_json = json.loads(response)
|
|
63
|
-
|
|
64
|
-
# Generate column names based on level depth
|
|
65
|
-
columns_info = response_json['data']['columns']
|
|
66
|
-
if levels == 3:
|
|
67
|
-
columns_map = {
|
|
68
|
-
col['index']: f"{col['group_level_0']} {col['group_level_1']} {col['label']}" for col in columns_info
|
|
69
|
-
}
|
|
70
|
-
elif levels == 2:
|
|
71
|
-
columns_map = {
|
|
72
|
-
col['index']: f"{col['group_level_0']} {col['label']}" for col in columns_info
|
|
73
|
-
}
|
|
74
|
-
else: # levels == 1
|
|
75
|
-
columns_map = {
|
|
76
|
-
col['index']: col['group_level_0'] for col in columns_info
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
# Build records
|
|
80
|
-
data_records = []
|
|
81
|
-
for entry in response_json['data']['timeseries']:
|
|
82
|
-
record = {'datetime': entry['from']}
|
|
83
|
-
for idx, value in enumerate(entry['values']):
|
|
84
|
-
if idx in columns_map:
|
|
85
|
-
record[columns_map[idx]] = value
|
|
86
|
-
data_records.append(record)
|
|
87
|
-
|
|
88
|
-
# Create DataFrame
|
|
89
|
-
df = pd.DataFrame(data_records)
|
|
90
|
-
df['datetime'] = pd.to_datetime(df['datetime']).dt.tz_convert('Europe/Vilnius').dt.tz_localize(None)
|
|
91
|
-
df.set_index('datetime', inplace=True)
|
|
92
|
-
|
|
93
|
-
return df
|
|
94
|
-
|
|
95
|
-
def procured_balancing_reserve_prices_df(self) -> pd.DataFrame:
|
|
96
|
-
"""Get df of TSO procured balancing reserve prices (EUR/MW)."""
|
|
97
|
-
response = self._get_data(api_id='price_procured_reserves')
|
|
98
|
-
return self._unravel_response(response, levels=3)
|
|
99
|
-
|
|
100
|
-
def procured_balancing_reserve_volumes_df(self) -> pd.DataFrame:
|
|
101
|
-
"""Get df of TSO procured balancing reserve volumes (MW)."""
|
|
102
|
-
response = self._get_data(api_id='procured_reserves')
|
|
103
|
-
return self._unravel_response(response, levels=3)
|
|
104
|
-
|
|
105
|
-
def cbmp_df(self) -> pd.DataFrame:
|
|
106
|
-
"""Get df of cross border marginal prices (EUR/MWh)."""
|
|
107
|
-
response = self._get_data(api_id='cross_border_marginal_price')
|
|
108
|
-
return self._unravel_response(response, levels=3)
|
|
109
|
-
|
|
110
|
-
def afrr_bid_prices_df(self) -> pd.DataFrame:
|
|
111
|
-
"""Get df of offered min/max afrr prices."""
|
|
112
|
-
response = self._get_data(api_id='afrr_bid_prices')
|
|
113
|
-
return self._unravel_response(response, levels=3)
|
|
114
|
-
|
|
115
|
-
def da_mfrr_bid_prices_df(self) -> pd.DataFrame:
|
|
116
|
-
"""Get df of offered min/max direct mfrr prices."""
|
|
117
|
-
response = self._get_data(api_id='da_mfrr_bid_prices')
|
|
118
|
-
return self._unravel_response(response, levels=3)
|
|
119
|
-
|
|
120
|
-
def sa_mfrr_bid_prices_df(self) -> pd.DataFrame:
|
|
121
|
-
"""Get df of offered min/max scheduled mfrr prices."""
|
|
122
|
-
response = self._get_data(api_id='sa_mfrr_bid_prices')
|
|
123
|
-
return self._unravel_response(response, levels=3)
|
|
124
|
-
|
|
125
|
-
def da_mfrr_bid_volumes_df(self) -> pd.DataFrame:
|
|
126
|
-
"""Get df of offered direct mfrr volumes."""
|
|
127
|
-
response = self._get_data(api_id='da_mfrr_bid_volumes')
|
|
128
|
-
return self._unravel_response(response, levels=2)
|
|
129
|
-
|
|
130
|
-
def sa_mfrr_bid_volumes_df(self) -> pd.DataFrame:
|
|
131
|
-
"""Get df of offered scheduled mfrr volumes."""
|
|
132
|
-
response = self._get_data(api_id='sa_mfrr_bid_volumes')
|
|
133
|
-
return self._unravel_response(response, levels=2)
|
|
134
|
-
|
|
135
|
-
def imbalance_volumes_df(self) -> pd.DataFrame:
|
|
136
|
-
"""Get df of imbalance volumes for each country (MWh)."""
|
|
137
|
-
response = self._get_data(api_id='imbalance_volumes_v2')
|
|
138
|
-
return self._unravel_response(response, levels=1)
|
|
139
|
-
|
|
140
|
-
def activated_afrr_volumes_df(self) -> pd.DataFrame:
|
|
141
|
-
"""Get df of activated afrr energy (MWh)"""
|
|
142
|
-
response = self._get_data(api_id='activations_afrr')
|
|
143
|
-
return self._unravel_response(response, levels=2)
|
|
144
|
-
|
|
145
|
-
def balancing_energy_ref_prices_df(self) -> pd.DataFrame:
|
|
146
|
-
"""Get df of balancing energy reference prices (EUR/MWh)."""
|
|
147
|
-
response = self._get_data(api_id='balancing_energy_prices')
|
|
148
|
-
return self._unravel_response(response, levels=2)
|
|
149
|
-
|
|
150
|
-
def current_balancing_state_df(self) -> pd.DataFrame:
|
|
151
|
-
"""Get df of imbalance volumes (MW) for each country with 1 minute resolution."""
|
|
152
|
-
response = self._get_data(api_id='current_balancing_state_v2')
|
|
153
|
-
return self._unravel_response(response, levels=1)
|
|
154
|
-
|
|
155
|
-
def direction_of_system_balancing_df(self) -> pd.DataFrame:
|
|
156
|
-
"""Get df of the directions of system balancing (-1/+1)."""
|
|
157
|
-
response = self._get_data(api_id='direction_of_balancing_v2')
|
|
158
|
-
return self._unravel_response(response, levels=1)
|
|
159
|
-
|
|
160
|
-
def imbalance_prices_df(self) -> pd.DataFrame:
|
|
161
|
-
"""Get df of imabalnce prices calculated by each Baltics TSO."""
|
|
162
|
-
response = self._get_data(api_id='imbalance_prices')
|
|
163
|
-
return self._unravel_response(response, levels=2)
|
|
164
|
-
|
|
165
|
-
def neutrality_component_df(self) -> pd.DataFrame:
|
|
166
|
-
"""Get df the neutrality components."""
|
|
167
|
-
response = self._get_data(api_id='neutrality_component')
|
|
168
|
-
return self._unravel_response(response, levels=1)
|
|
169
|
-
|
|
170
|
-
def local_marginal_prices_df(self) -> pd.DataFrame:
|
|
171
|
-
"""Get df of local marginal prices."""
|
|
172
|
-
response = self._get_data(api_id='local_marginal_price')
|
|
173
|
-
return self._unravel_response(response, levels=2)
|
|
174
|
-
|
|
175
|
-
def local_marginal_afrr_prices_df(self) -> pd.DataFrame:
|
|
176
|
-
"""Get df of clearing (marginal) aFRR prices (EUR/MWh)."""
|
|
177
|
-
response = self._get_data(api_id='local_marginal_price_afrr')
|
|
178
|
-
return self._unravel_response(response, levels=2)
|
|
179
|
-
|
|
180
|
-
def normal_activations_da_volumes_df(self) -> pd.DataFrame:
|
|
181
|
-
"""Get df of total direct mFRR energy activation volumes."""
|
|
182
|
-
response = self._get_data(api_id='normal_activations_da_mfrr')
|
|
183
|
-
return self._unravel_response(response, levels=2)
|
|
184
|
-
|
|
185
|
-
def normal_activations_sa_volumes_df(self) -> pd.DataFrame:
|
|
186
|
-
"""Get df of total scheduled mFRR energy activation volumes."""
|
|
187
|
-
response = self._get_data(api_id='normal_activations_sa_mfrr')
|
|
188
|
-
return self._unravel_response(response, levels=2)
|
|
189
|
-
|
|
190
|
-
def normal_activations_total_volumes_df(self) -> pd.DataFrame:
|
|
191
|
-
"""Get df of total normal balancing energy activated volumes."""
|
|
192
|
-
response = self._get_data(api_id='normal_activations_total')
|
|
193
|
-
return self._unravel_response(response, levels=2)
|
|
194
|
-
|
|
195
|
-
def total_satisfied_demand_for_balancing_purposes_df(self) -> pd.DataFrame:
|
|
196
|
-
"""Get df total satisfied demands for balancing purposes (MWh)."""
|
|
197
|
-
response = self._get_data(api_id='total_satisfied_demand_for_balancing_purposes')
|
|
198
|
-
df = self._unravel_response(response, levels=2)
|
|
199
|
-
return df
|
|
200
|
-
|
|
201
|
-
def total_satisfied_demand_for_balancing_purposes_mod_df(self) -> pd.DataFrame:
|
|
202
|
-
"""Get df total satisfied demands for balancing purposes. Convertet to MW and
|
|
203
|
-
total Baltics demand computed and returned."""
|
|
204
|
-
response = self._get_data(api_id='total_satisfied_demand_for_balancing_purposes')
|
|
205
|
-
df = self._unravel_response(response, levels=2)
|
|
206
|
-
|
|
207
|
-
# Apply processing logic
|
|
208
|
-
downward_columns = [col for col in df.columns if "Downward" in col]
|
|
209
|
-
df[downward_columns] = df[downward_columns].apply(pd.to_numeric, errors='coerce') * -1
|
|
210
|
-
df = df.dropna()
|
|
211
|
-
df['Baltics_net'] = df.sum(axis=1)
|
|
212
|
-
df *= 4
|
|
213
|
-
return df
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|