Skip to content

Commit e4ab832

Browse files
authored
Add calamine as engine for reading Excel files (#190)
1 parent 4d11b7b commit e4ab832

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

docs/release_notes.rst

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Upcoming Release
3434

3535
* Add `purge` and `all` rules to clean all generated outputs and regenerate them (https://github.com/PyPSA/technology-data/pull/187)
3636

37+
* Switch to `python-calamine` as engine for reading Excel files in `pandas`, greatly improving performance (https://github.com/PyPSA/technology-data/pull/188)
38+
3739
`v0.11.0 <https://github.com/PyPSA/technology-data/releases/tag/v0.11.0>`__ (24th January 2025)
3840
=======================================================================================
3941

environment.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@ dependencies:
1919
- xlrd
2020
- scipy
2121
- openpyxl>=3.1.2
22+
- python-calamine
2223
- packaging
2324
- pytest
2425

2526
# Development dependencies
2627
- pre-commit
2728
- ruff
2829

30+
# Interactive execution
31+
- ipykernel
32+
2933
- pip:
3034
- tabula-py
3135
- currencyconverter

scripts/compile_cost_assumptions.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ def get_dea_maritime_data(
376376
index_col=[0, 1],
377377
usecols="A:F",
378378
na_values="N/A",
379+
engine="calamine",
379380
)
380381

381382
wished_index = [
@@ -500,6 +501,7 @@ def get_dea_vehicle_data(
500501
index_col=0,
501502
usecols="A:F",
502503
na_values="no data",
504+
engine="calamine",
503505
)
504506

505507
wished_index = [
@@ -667,6 +669,7 @@ def get_data_DEA(
667669
usecols=usecols,
668670
skiprows=skiprows,
669671
na_values="N.A",
672+
engine="calamine",
670673
)
671674

672675
excel.dropna(axis=1, how="all", inplace=True)
@@ -2439,6 +2442,7 @@ def add_gas_storage(
24392442
gas_storage_file_name,
24402443
sheet_name="150 Underground Storage of Gas",
24412444
index_col=1,
2445+
engine="calamine",
24422446
)
24432447
gas_storage.dropna(axis=1, how="all", inplace=True)
24442448

@@ -3666,6 +3670,7 @@ def add_energy_storage_database(
36663670
"ref_size_MW": float,
36673671
"EP_ratio_h": float,
36683672
},
3673+
engine="calamine",
36693674
)
36703675
df = df.drop(columns=["ref_size_MW", "EP_ratio_h"])
36713676
df = df.fillna(df.dtypes.replace({"float64": 0.0, "O": "NULL"}))
@@ -3939,7 +3944,9 @@ def prepare_inflation_rate(fn: str) -> pd.Series:
39393944
inflation rates series
39403945
"""
39413946

3942-
inflation_rate = pd.read_excel(fn, sheet_name="Sheet 1", index_col=0, header=[8])
3947+
inflation_rate = pd.read_excel(
3948+
fn, sheet_name="Sheet 1", index_col=0, header=[8], engine="calamine"
3949+
)
39433950
inflation_rate = (
39443951
inflation_rate.loc["European Union - 27 countries (from 2020)"].dropna()
39453952
).loc["2001"::]

0 commit comments

Comments
 (0)