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

Add calamine as engine for reading Excel files #190

Merged
merged 1 commit into from
Mar 12, 2025
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
2 changes: 2 additions & 0 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Upcoming Release

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

* Switch to `python-calamine` as engine for reading Excel files in `pandas`, greatly improving performance (https://github.com/PyPSA/technology-data/pull/188)

`v0.11.0 <https://github.com/PyPSA/technology-data/releases/tag/v0.11.0>`__ (24th January 2025)
=======================================================================================

Expand Down
4 changes: 4 additions & 0 deletions environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ dependencies:
- xlrd
- scipy
- openpyxl>=3.1.2
- python-calamine
- packaging
- pytest

# Development dependencies
- pre-commit
- ruff

# Interactive execution
- ipykernel

- pip:
- tabula-py
- currencyconverter
9 changes: 8 additions & 1 deletion scripts/compile_cost_assumptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ def get_dea_maritime_data(
index_col=[0, 1],
usecols="A:F",
na_values="N/A",
engine="calamine",
)

wished_index = [
Expand Down Expand Up @@ -500,6 +501,7 @@ def get_dea_vehicle_data(
index_col=0,
usecols="A:F",
na_values="no data",
engine="calamine",
)

wished_index = [
Expand Down Expand Up @@ -667,6 +669,7 @@ def get_data_DEA(
usecols=usecols,
skiprows=skiprows,
na_values="N.A",
engine="calamine",
)

excel.dropna(axis=1, how="all", inplace=True)
Expand Down Expand Up @@ -2439,6 +2442,7 @@ def add_gas_storage(
gas_storage_file_name,
sheet_name="150 Underground Storage of Gas",
index_col=1,
engine="calamine",
)
gas_storage.dropna(axis=1, how="all", inplace=True)

Expand Down Expand Up @@ -3666,6 +3670,7 @@ def add_energy_storage_database(
"ref_size_MW": float,
"EP_ratio_h": float,
},
engine="calamine",
)
df = df.drop(columns=["ref_size_MW", "EP_ratio_h"])
df = df.fillna(df.dtypes.replace({"float64": 0.0, "O": "NULL"}))
Expand Down Expand Up @@ -3939,7 +3944,9 @@ def prepare_inflation_rate(fn: str) -> pd.Series:
inflation rates series
"""

inflation_rate = pd.read_excel(fn, sheet_name="Sheet 1", index_col=0, header=[8])
inflation_rate = pd.read_excel(
fn, sheet_name="Sheet 1", index_col=0, header=[8], engine="calamine"
)
inflation_rate = (
inflation_rate.loc["European Union - 27 countries (from 2020)"].dropna()
).loc["2001"::]
Expand Down
Loading