Skip to content

Commit 9af00c2

Browse files
committed
Addressing comments
1 parent 864fc1a commit 9af00c2

1 file changed

Lines changed: 52 additions & 67 deletions

File tree

examples/00_getting_started.py

Lines changed: 52 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@
4343
TableReport(employees_df)
4444

4545
# %%
46-
#
4746
# You can use the interactive display above to explore the dataset visually.
4847
#
48+
# It is also possible to tell skrub to replace the default pandas & polars
49+
# displays with |TableReport| by modifying the global config with
50+
# |set_config|.
51+
#
4952
# .. note::
5053
#
5154
# You can see a few more `example reports`_ online. We also
@@ -72,24 +75,6 @@
7275
employees_df = Cleaner().fit_transform(employees_df)
7376
TableReport(employees_df)
7477

75-
# %%
76-
# It is also possible to tell skrub to replace the default pandas & polars
77-
# displays with |TableReport| by modifying the global config with
78-
# |set_config|.
79-
80-
from skrub import set_config
81-
82-
set_config(use_table_report=True)
83-
84-
employees_df
85-
86-
# %%
87-
# This setting can easily be reverted:
88-
89-
set_config(use_table_report=False)
90-
91-
employees_df
92-
9378
# %%
9479
# Easily building a strong baseline for tabular machine learning
9580
# --------------------------------------------------------------
@@ -117,54 +102,6 @@
117102
# :ref:`user_guide_tabular_pipeline`.
118103

119104

120-
# %%
121-
# Assembling data
122-
# ---------------
123-
#
124-
# Skrub allows imperfect assembly of data, such as joining dataframes
125-
# on columns that contain typos. Skrub's joiners have ``fit`` and
126-
# ``transform`` methods, storing information about the data across calls.
127-
#
128-
# The |Joiner| allows fuzzy-joining multiple tables, where each row of
129-
# a main table will be augmented with values from the best match in the auxiliary table.
130-
# You can control how distant fuzzy-matches are allowed to be with the
131-
# ``max_dist`` parameter.
132-
133-
# %%
134-
# In the following, we add information about countries to a table containing
135-
# airports and the cities they are in:
136-
137-
# %%
138-
import pandas as pd
139-
140-
from skrub import Joiner
141-
142-
airports = pd.DataFrame(
143-
{
144-
"airport_id": [1, 2],
145-
"airport_name": ["Charles de Gaulle", "Aeroporto Leonardo da Vinci"],
146-
"city": ["Paris", "Roma"],
147-
}
148-
)
149-
# Notice the "Rome" instead of "Roma"
150-
capitals = pd.DataFrame(
151-
{"capital": ["Berlin", "Paris", "Rome"], "country": ["Germany", "France", "Italy"]}
152-
)
153-
joiner = Joiner(
154-
capitals,
155-
main_key="city",
156-
aux_key="capital",
157-
max_dist=0.8,
158-
add_match_info=False,
159-
)
160-
joiner.fit_transform(airports)
161-
162-
# %%
163-
# Information about countries has been added, even if the rows aren't exactly matching.
164-
#
165-
# Skrub allows you to aggregate multiple tables according to various strategies. You
166-
# can see other ways to join multiple tables in :ref:`user_guide_joining_dataframes`.
167-
168105
# %%
169106
# Encoding any data as numerical features
170107
# ---------------------------------------
@@ -241,6 +178,54 @@
241178
# provided by skrub, and :ref:`sphx_glr_auto_examples_01_encodings.py` for a
242179
# comparison between the different methods.
243180

181+
# %%
182+
# Assembling data
183+
# ---------------
184+
#
185+
# Skrub allows imperfect assembly of data, such as joining dataframes
186+
# on columns that contain typos. Skrub's joiners have ``fit`` and
187+
# ``transform`` methods, storing information about the data across calls.
188+
#
189+
# The |Joiner| allows fuzzy-joining multiple tables, where each row of
190+
# a main table will be augmented with values from the best match in the auxiliary table.
191+
# You can control how distant fuzzy-matches are allowed to be with the
192+
# ``max_dist`` parameter.
193+
194+
# %%
195+
# In the following, we add information about countries to a table containing
196+
# airports and the cities they are in:
197+
198+
# %%
199+
import pandas as pd
200+
201+
from skrub import Joiner
202+
203+
airports = pd.DataFrame(
204+
{
205+
"airport_id": [1, 2],
206+
"airport_name": ["Charles de Gaulle", "Aeroporto Leonardo da Vinci"],
207+
"city": ["Paris", "Roma"],
208+
}
209+
)
210+
# Notice the "Rome" instead of "Roma"
211+
capitals = pd.DataFrame(
212+
{"capital": ["Berlin", "Paris", "Rome"], "country": ["Germany", "France", "Italy"]}
213+
)
214+
joiner = Joiner(
215+
capitals,
216+
main_key="city",
217+
aux_key="capital",
218+
max_dist=0.8,
219+
add_match_info=False,
220+
)
221+
joiner.fit_transform(airports)
222+
223+
# %%
224+
# Information about countries has been added, even if the rows aren't exactly matching.
225+
#
226+
# Skrub allows you to aggregate multiple tables according to various strategies. You
227+
# can see other ways to join multiple tables in :ref:`user_guide_joining_dataframes`.
228+
244229
# %%
245230
# Advanced use cases
246231
# ----------------------

0 commit comments

Comments
 (0)