Skip to content
Skills Library
Data & analytics · Building & coding

data-preparation

/data-preparation

Data Preparation. Clean, join and split data without leakage - data cleaning, joins and merges with row-count checks, deduplication, missing value imputation, type fixes, outlier handling, train test split, validation split, cross-validation folds, stratified, group-aware and time-series (forward-chaining) splits, scikit-learn Pipeline and ColumnTransformer. Use for data wrangling, preprocessing, data cleaning, ETL for machine learning, or any request to prepare data for a model. CRISP-DM Data Preparation.

Licence
MIT
Last repository change
31.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
2
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 31.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Data Preparation. Clean, join and split data without leakage - data cleaning, joins and merges with row-count checks, deduplication, missing value imputation, type fixes, outlier handling, train test split, validation split, cross-validation folds, stratified, group-aware and time-series (forward-chaining) splits, scikit-learn Pipeline and ColumnTransformer. Use for data wrangling, preprocessing, data cleaning, ETL for machine learning, or any request to prepare data for a model. CRISP-DM Data Preparation.

Original author description

Data Preparation. Clean, join and split data without leakage - data cleaning, joins and merges with row-count checks, deduplication, missing value imputation, type fixes, outlier handling, train test split, validation split, cross-validation folds, stratified, group-aware and time-series (forward-chaining) splits, scikit-learn Pipeline and ColumnTransformer. Use for data wrangling, preprocessing, data cleaning, ETL for machine learning, or any request to prepare data for a model. CRISP-DM Data Preparation.

How it works

  1. Order of work
  2. Missing values
  3. Outliers
  4. Checks before modeling
Original SKILL.md headings · 46 lines, 363 words
SKILL.md preview
---
name: data-preparation
description: Data Preparation. Clean, join and split data without leakage - data cleaning, joins and merges with row-count checks, deduplication, missing value imputation, type fixes, outlier handling, train test split, validation split, cross-validation folds, stratified, group-aware and time-series (forward-chaining) splits, scikit-learn Pipeline and ColumnTransformer. Use for data wrangling, preprocessing, data cleaning, ETL for machine learning, or any request to prepare data for a model. CRISP-DM Data Preparation.
---

# Data Preparation

Every transformation is either a deterministic cleaning step (applied once, before splitting, with no learned statistics) or a learned step (fitted inside the pipeline on training folds only). Mixing them up is the most common leak.

## Order of work

1. **Deterministic cleaning, before the split.** Fix types, parse dates, standardize units and category spellings, remove exact duplicates, drop rows with an invalid target, remove post-event columns. Print the row count after each step.
2. **Joins with assertions.**
   ```python
   n = len(left)
   out = left.merge(right, on="customer_id", how="left", validate="many_to_one")
   assert len(out) == n, f"join changed rows: {n} -> {len(out)}"
   ```
3. **Choose the split** from the data (`references/split-strategies.md`):
   - Independent rows, classification: stratified.
   - Repeated entities: group-aware (`GroupKFold`, `StratifiedGroupKFold`, `GroupShuffleSplit`).
   - Time-ordered data: forward-chaining (`TimeSeriesSplit` or a cutoff date), with a gap equal to the label horizon.
   Fix and record the seed. Hold out the test set now; it is touched once, at evaluation.
4. **Learned steps inside the pipeline.** Imputers, scalers, encoders, winsorizers, selectors, resamplers and target encoders go into a `ColumnTransformer` and `Pipeline` (or an imbalanced-learn `Pipeline` when resampling). Fit happens on training folds only, through cross-validation or one `fit` on the training split.
5. **Document** every transformation in the feature dictionary: what, why, and when the input is available.

## Missing values

| Mechanism | Default |
|---|---|
| MCAR, small share | `SimpleImputer(strategy="median")` |
| MAR | `IterativeImputer` or `KNNImputer` inside the pipeline |
| MNAR or informative | Imputer with `add_indicator=True`; state the assumption |
| Inference (statistics, not prediction) | Multiple imputation, pooled estimates |

Never fill with a statistic computed on the full frame before splitting.

## Outliers

Decide error or signal first. Errors are fixed or removed with a written rule and a count. Signal is kept and handled with robust scaling, winsorizing inside the pipeline, or robust losses.

## Checks before modeling

- `X_train.shape`, `X_test.shape`, positive counts per split, no shared entity ids across splits.
- `df.duplicated().sum()` before splitting is zero or explained.
- No column recorded after the prediction time.
- The pipeline object prints cleanly and `pipeline.fit(X_train, y_train)` runs.

Conditions that change preparation (skew, zero inflation, high cardinality, drift): `data-profiling/references/scenarios.md`.
Files in this package (2)
  • SKILL.md 3 KB
  • references/split-strategies.md 2 KB

Versions

The database has no other skills named data-preparation.

Database snapshot: 13.11.2026 · package version 7ffc4b555e84 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100scikit-learn
    Assists with building, evaluating, and deploying machine learning models using scikit-learn. Use when performing data preprocessing, feature engineering, model selection, hyperparameter tuning, cross-validation, or building pipelines for classification, regression, and…
  • 100scikit-learn
    Expert Scikit-Learn assistance covering classification, regression, clustering, pipelines, cross-validation, and preprocessing. Use when building classical machine learning models and feature engineering pipelines.
  • 100sklearn-pipelines
    Use when building scikit-learn models that must not leak preprocessing. Covers Pipeline, ColumnTransformer, custom transformers, and combining preprocessing with cross-validation correctly.
  • 90data-cleaning
    Cleans and preprocesses financial time series data. Handles missing values, outliers, corporate actions (splits, dividends), date alignment, and data quality checks. Trigger when the user has messy financial data or needs to prepare data for analysis.
  • 100ml-data-leakage
    Prevents train/test leakage when writing or reviewing machine learning code. Use when splitting data, building preprocessing or feature selection steps, setting up cross-validation, oversampling, or when a validation score looks too good. Covers scalers, encoders, imputers,…
  • 100preprocessing-data-with-automated-pipelines
    Process automate data cleaning, transformation, and validation for ML tasks. Use when requesting "preprocess data", "clean data", "ETL pipeline", or "data transformation". Trigger with relevant phrases based on skill purpose.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.