Skip to content

Commit b0ef47d

Browse files
committed
DOC update remaining gallery examples to load datasets from paths
1 parent d9be7aa commit b0ef47d

4 files changed

Lines changed: 17 additions & 7 deletions

File tree

CHANGES.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,15 @@ Bug Fixes
6666
- :class:`CheckInputDataFrame` no longer collects Polars LazyFrames automatically;
6767
a ``TypeError`` is now raised instead, consistent with the rest of the library.
6868
:pr:`1941` by :user:`Mudit Atrey <MuditAtrey>`.
69+
- :func:`fetch_employee_salaries` now correctly writes the train and test
70+
split CSV files to their respective paths when ``split`` is specified.
71+
:pr:`1964` by :user:`MuditAtrey <MuditAtrey>`.
6972

7073
Documentation
7174
-------------
7275
- Updated gallery examples to load datasets from their file paths using
7376
``pd.read_csv()``, following the pattern established in :pr:`1852`.
74-
:pr:`1940` by :user:`MuditAtrey <MuditAtrey>`.
77+
:pr:`1940` and :pr:`1964` by :user:`MuditAtrey <MuditAtrey>`.
7578

7679
Release 0.7.2
7780
=============

examples/FIXME/07_grid_searching_with_the_tablevectorizer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@
3232
#
3333
# Throughout this example, we will use the employee salaries dataset.
3434

35+
import pandas as pd
36+
3537
from skrub.datasets import fetch_employee_salaries
3638

3739
dataset = fetch_employee_salaries()
38-
X = dataset.X
39-
y = dataset.y
40+
df = pd.read_csv(dataset.employee_salaries_path)
41+
X = df.drop(columns=["current_annual_salary"])
42+
y = df["current_annual_salary"]
4043

4144
X.head(10)
4245

examples/data_ops/1110_data_ops_intro.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@
4646
# By default, the |fetch_employee_salaries| function returns the training set.
4747
# We will load the test set later, to evaluate our model on unseen data.
4848

49+
import pandas as pd
50+
4951
from skrub.datasets import fetch_employee_salaries
5052

51-
training_data = fetch_employee_salaries(split="train").employee_salaries
53+
training_data = pd.read_csv(
54+
fetch_employee_salaries(split="train").employee_salaries_path
55+
)
5256

5357
# %%
5458
# We can take a look at the dataset using the |TableReport|.
@@ -160,7 +164,7 @@
160164
# case, "data").
161165
#
162166
# We can now get the test set of the employee salaries dataset:
163-
unseen_data = fetch_employee_salaries(split="test").employee_salaries
167+
unseen_data = pd.read_csv(fetch_employee_salaries(split="test").employee_salaries_path)
164168

165169
# %%
166170
# Then, we can use the loaded model to make predictions on the unseen data by

skrub/datasets/_fetching.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def fetch_employee_salaries(data_home=None, split="all"):
6464
)
6565
dataset["employee_salaries_path"] = str(train_path)
6666
dataset["path"] = str(train_path)
67-
dataset["employee_salaries"][:id_split].to_csv(str(train_path), index=False)
67+
dataset["employee_salaries"].to_csv(str(train_path), index=False)
6868
dataset["X"] = dataset["X"][:id_split]
6969
dataset["y"] = dataset["y"][:id_split]
7070
elif split == "test":
@@ -74,7 +74,7 @@ def fetch_employee_salaries(data_home=None, split="all"):
7474
)
7575
dataset["employee_salaries_path"] = str(test_path)
7676
dataset["path"] = str(test_path)
77-
dataset["employee_salaries"][id_split:].to_csv(str(test_path), index=False)
77+
dataset["employee_salaries"].to_csv(str(test_path), index=False)
7878
dataset["X"] = dataset["X"][id_split:]
7979
dataset["y"] = dataset["y"][id_split:]
8080
return dataset

0 commit comments

Comments
 (0)