Skip to content

Commit 2e1d8d8

Browse files
committed
Accept string timestamps with default Europe/Brussels timezone
Client(tz=...) sets a default timezone (Europe/Brussels) so users can pass plain date strings instead of verbose pd.Timestamp objects. Existing pd.Timestamp inputs still work and take priority.
1 parent d02dbed commit 2e1d8d8

16 files changed

Lines changed: 372 additions & 31659 deletions

README.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,21 @@ pip install python-entsoe
1212

1313
```python
1414
from entsoe import Client
15-
import pandas as pd
1615

1716
client = Client() # reads ENTSOE_API_KEY from environment
1817

19-
start = pd.Timestamp("2024-06-01", tz="Europe/Paris")
20-
end = pd.Timestamp("2024-06-08", tz="Europe/Paris")
18+
df = client.load.actual("2024-06-01", "2024-06-08", country="FR")
19+
```
2120

22-
df = client.load.actual(start, end, country="FR")
21+
Strings are interpreted as timestamps in `Europe/Brussels` (CET — the ENTSO-E standard). You can override this per-client or pass `pd.Timestamp` objects directly:
22+
23+
```python
24+
client = Client(tz="UTC") # override default timezone
25+
26+
# pd.Timestamp still works — its timezone takes priority
27+
import pandas as pd
28+
start = pd.Timestamp("2024-06-01", tz="Europe/Paris")
29+
df = client.load.actual(start, "2024-06-08", country="FR")
2330
```
2431

2532
Every method returns a `pandas.DataFrame` with a `timestamp` column (UTC) and a `value` column.
@@ -158,15 +165,24 @@ print(PSR_TYPES["B16"]) # "Solar"
158165

159166
## Timestamps
160167

161-
All `start` and `end` parameters must be **timezone-aware** `pd.Timestamp` objects:
168+
All `start` and `end` parameters accept **date strings** or **tz-aware `pd.Timestamp`** objects:
162169

163170
```python
164-
# Correct
165-
start = pd.Timestamp("2024-01-01", tz="Europe/Paris")
166-
start = pd.Timestamp("2024-01-01", tz="UTC")
171+
# Simple — just strings (uses client's default tz: Europe/Brussels)
172+
df = client.load.actual("2024-01-01", "2024-01-07", country="FR")
173+
174+
# pd.Timestamp with explicit timezone — takes priority over default
175+
df = client.load.actual(
176+
pd.Timestamp("2024-01-01", tz="Europe/Paris"),
177+
pd.Timestamp("2024-01-07", tz="Europe/Paris"),
178+
country="FR",
179+
)
180+
181+
# Mixing is fine
182+
df = client.load.actual("2024-01-01", pd.Timestamp("2024-01-07", tz="UTC"), country="FR")
167183

168-
# Wrong — will raise InvalidParameterError
169-
start = pd.Timestamp("2024-01-01")
184+
# Naive pd.Timestamp (no tz) — still raises InvalidParameterError
185+
start = pd.Timestamp("2024-01-01") # ← no tz, will error
170186
```
171187

172188
Returned timestamps are always in **UTC**.

0 commit comments

Comments
 (0)