Skip to content

Prepare recipes and their exports

Clean a dataset as a list of steps that never touches the original, then export the same recipe to SQL, pandas or dplyr.

Introductory ~9 min8 steps

What runs in CodeSplash

You will be able to

  • Explain why a recipe leaves the original data untouched
  • Add suggested fixes and read a step's before-and-after
  • Apply a recipe to a new dataset and export it as code

Read first

01

Cleaning you can read back

Read

Most data cleaning disappears: a formula here, a deleted row there, nothing to show what changed. A recipeRecipeAn ordered list of data-preparation steps that replays on new versions and exports to SQL, pandas and dplyr. in Prepare (⌘3) is a list of steps instead. Each step records what it did, and the source dataset is never modified.

Because the steps are data, you can reorder them, turn one off, compare two versions, and rerun the lot on next month's file.

Messy customer list
02

Should a recipe fix this by itself?

Predict

Predict first

Add all safe fixes adds the suggestions that cannot change what your data means. Which of these do you expect it to add without asking?

Trim stray spaces in cityTurn -99 in age into missingBothNeither
Reveal

Trimming spaces. It only tidies a value. Deciding that -99 means unknown is a claim about the data, even though it is probably right, so that one stays your decision: you read it and add it yourself.

03

Start a recipe

In the app

In Prepare, press New recipe, pick the messy customer list and create it. Open Suggested fixes on the right: CodeSplash profiled the data and drafted steps for what it found, each with Why it matters.

Add the safe ones, then add the sentinel fix for age yourself.

Select any step. The workspace shows what that step changes, so you can catch a mistake before it reaches the next one.

04

Learned values

Explore

Some steps learn from the data: a median to fill gaps, a list of category levels, the bounds for capping. Add a Fill missing values step on spend_30d with the median and read the value it learned.

Those values are stored in the recipe. If your data changes, Refit learned values recomputes them on all rows. That difference matters for modeling: learned values fitted on all your data leak information into a test set, which is why the scikit-learn and recipes exports refit on training data.

05

Apply, then export

In the app

Apply recipe runs every step on all rows and writes the output as a new dataset or the next version of the recipe's output, recording where it came from. Your source stays where it was.

Code gives you the same recipe five ways: SQL, pandas, dplyr, scikit-learn and recipes. The first three reproduce the app's output, with learned values written in. Copy one, or use Open as script.

Column lineage shows where every output column came from, and History compares and restores versions.

06

Check your understanding

Checkpoint

Check yourself

You apply a recipe that removes 12 duplicate customers. What happens to the source dataset?

Show the answer

Answer: b

Source data is never changed. That is what lets you see exactly what a recipe did and go back when it was wrong.

Check yourself

You are building a model and want a preprocessing pipeline that does not leak test rows into its learned values. Which export fits?

Show the answer

Answer: c

SQL, pandas and dplyr write the learned values in, which reproduces the app. A pipeline you fit on training data recomputes them, which is what honest validation needs.

07

Where would this save you?

Reflect

Think of the last spreadsheet you cleaned by hand. Could you redo it next month from memory? Which step would you most want written down?

A cleaned column is often ready for a transform test. For example, a skewed measure might suit a power transform:

08

Recap

Recap
  • A recipe is a readable list of steps; the source is never changed.
  • Suggested fixes separate safe tidying from decisions about meaning.
  • Apply writes a new version; Code exports the same recipe to SQL, pandas, dplyr, scikit-learn or recipes.

Concepts in this lesson