Skip to content

Commit ccc2f7b

Browse files
committed
Workaround pyodide / polars limitations
1 parent 5aaf6f4 commit ccc2f7b

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

content/python_files/feature_engineering.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
# jupyterlite). We need the development version of skrub to be able to use the
55
# skrub expressions.
66
# %%
7+
# %pip install -q https://pypi.anaconda.org/ogrisel/simple/polars/1.24.0/polars-1.24.0-cp39-abi3-emscripten_3_1_58_wasm32.whl
78
# %pip install -q holidays https://pypi.anaconda.org/ogrisel/simple/skrub/0.6.dev0/skrub-0.6.dev0-py3-none-any.whl
8-
99
# %%
1010
import polars as pl
11+
import pandas as pd
12+
from pyarrow.parquet import read_table
1113
import skrub
1214
from pathlib import Path
1315

@@ -38,7 +40,7 @@
3840
"electricity_raw",
3941
pl.concat(
4042
[
41-
pl.read_csv(data_file, null_values=["N/A"])
43+
pl.from_pandas(pd.read_csv(data_file, na_values=["N/A"]))
4244
for data_file in sorted(data_source_folder.iterdir())
4345
if data_file.name.startswith("Total Load - Day Ahead")
4446
and data_file.name.endswith(".csv")
@@ -96,7 +98,7 @@
9698
for city_name in city_names:
9799
all_city_weather_raw[city_name] = skrub.var(
98100
f"{city_name}_weather_raw",
99-
pl.read_parquet(f"../datasets/weather_{city_name}.parquet"),
101+
pl.from_arrow(read_table(f"../datasets/weather_{city_name}.parquet")),
100102
).with_columns(
101103
[
102104
pl.col("time").dt.cast_time_unit(
@@ -116,7 +118,6 @@
116118
time.join(all_city_weather_raw["brest"], on="time", how="left")
117119

118120

119-
120121
# %%
121122
all_city_weather = time
122123
for city_name, city_weather_raw in all_city_weather_raw.items():

0 commit comments

Comments
 (0)