DistilKaggle: A Distilled Dataset of Kaggle Jupyter Notebooks

Sharif University of Technology
MSR 2024 · Data and Tool Showcase Track

*Also affiliated with Bowling Green State University, as noted in the paper.

Overview

DistilKaggle pairs extracted code and Markdown with computed notebook features: measures of code size, complexity, documentation, and notebook structure.

The paper describes 34 metrics and a combined collection of 542,051 notebooks, enabling analysis beyond the original cell content.

The archived release covers publicly available Python notebooks from September 2015 to October 2023. The code and Markdown collection covers 542,051 notebooks; the metrics CSV covers over 517,000. These are different coverage counts, not interchangeable totals.

Usage. Researchers can use DistilKaggle to analyze notebook content, study relationships between code and documentation, or select notebooks based on their metrics.

Sources: MSR 2024 paper and Zenodo v1 release.

Dataset Construction

From notebook content to structured cells and computed features.

293,290 notebooksCollected from Kaggle
October 2020–October 2023
248,761 notebooksFrom KGTorrent
Earlier Kaggle collection
542,051 notebooksCombined collection reported in the paper
Extract cell contentPreserve code, Markdown, cell positions,
and selected saved metadata
code.csvCode cells
markdown.csvMarkdown cells
Compute notebook metricsMeasure cells with text rules & Radon
Aggregate by notebook: sums, means & maxima
notebook_metrics.csvNotebook featuresCode size, complexity & documentation
Subset of over 517,000 notebooks
Figure 1. Collection, cell extraction, and metric computation, summarized from the paper and processing scripts. File coverage follows the Zenodo release.

Dataset

Start with the metrics file for notebook-level analysis, or download the cell files to work directly with source content.

Scroll horizontally to see file sizes and download links.

Table 1. Main dataset files · Zenodo v1
FileContentsFile sizeDownload
notebook_metrics.csvNotebook features for over 517,000 notebooks121.1 MBMetrics CSV
code.csvOver 12 million code-cell rows3.9 GBCode CSV
markdown.csvOver 5 million Markdown-cell rows1.5 GBMarkdown CSV
DistilKaggle.tar.gzCompressed dataset bundle1.6 GBDataset archive

Choose the archive or the individual CSVs; you do not need both. Sizes are the rounded download sizes listed on Zenodo. The archive is compressed, while the CSV sizes are uncompressed.

How the cell files connect

Use kernel_id to identify a notebook and cell_index to order its cells. Both downloaded cell files use these keys.

Scroll horizontally to see every field description.

Table 2. Verified headers of the released cell CSVs
FieldAvailable inMeaning
kernel_idBoth cell filesKaggle notebook identifier
cell_indexBoth cell filesPosition of the cell within the notebook
sourceBoth cell filesThe cell’s code or Markdown text
output_typeCode cellsType of the first recorded output, when present
execution_countCode cellsRecorded execution counter, when present

Headers verified against the released CSVs; field behavior follows the cell extraction script. The script’s version-ID field is not present in these released headers. These CSVs retain source and selected metadata; they do not package the original runtime, dependencies, input datasets, or complete output payloads.

Notebook Metrics

Metrics describe code, documentation, and notebook structure: code lines measure size, cyclomatic complexity captures control-flow complexity, and Markdown word and heading counts describe documentation.

The cell analysis script uses text rules and Radon’s static code analysis, without rerunning notebooks. A second script aggregates by notebook using sums, means, or maxima—for example, total code lines and mean words per Markdown cell. Saved metadata supplies output types and author tier.

Scroll within the table to browse all 34 metrics. Scroll horizontally to see metric names.

Table 3. Metric reference adapted from Table 1 of the paper
GroupPaper abbreviationMetric
Basic codeLOCLines of code
Basic codeBLCBlank code lines
Basic codeLOComComment lines
Basic codeCWWords in comments
Basic codeSStatements
Basic codePParameters
Basic codeUDFUser-defined functions
ComplexityCyCCyclomatic complexity
ComplexityNBDNested block depth
ComplexityKLCIDKind of line of code identifier density
HalsteadOPRNDOperands
HalsteadOPRATOperators
HalsteadUOPRNDUnique operands
HalsteadUOPRATUnique operators
ReadabilityALLCAverage code line length
ReadabilityIDIdentifiers
ReadabilityAIDAverage number of identifiers
NotebookCCCode cells
NotebookMeanLCCMean lines per code cell
NotebookIImports
NotebookMeanWMCMean words per Markdown cell
NotebookH1Level-one Markdown headings
NotebookH2Level-two Markdown headings
NotebookH3Level-three Markdown headings
NotebookMCMarkdown cells
NotebookMeanLMCMean lines per Markdown cell
NotebookMWMarkdown words
NotebookLMCLines in Markdown cells
NotebookDMCDistribution of Markdown cells
NotebookDIDistribution of imports
NotebookPTAuthor performance tier
NotebookEAPExternal API popularity
NotebookNVDVisualization outputs
NotebookECExecuted cells

The table follows the paper’s metric vocabulary; implementation names and definitions can differ. Check the CSV header and linked scripts before analysis. These features support research on quality; they are not validated quality scores on their own.

Sample Application

The repository’s example explores predicting an author’s Kaggle Performance Tier from notebook metrics with a Random Forest classifier.

The saved notebook balances classes with random undersampling, uses an 80/20 training/test split, and reports 0.56 accuracy on 8,884 test examples. External API popularity (EAP) has the highest feature importance in that saved run.

The figures and numbers below are archived outputs from the example notebook. They have not been recomputed for this website. The saved run includes target labels 0–5; these are shown as recorded, without assigning tier names.

Saved confusion matrix for six target labels, 0 through 5. Most confusion occurs between labels 0 through 4; label 5 is separated more strongly.
Figure 2. Confusion matrix from the repository’s saved example. Rows are actual labels and columns are predictions. Select the image to view it at full size.
Saved Random Forest feature-importance chart. EAP leads at 0.099952, followed by imports at 0.037969 and H2 headings at 0.037248.
Figure 3. Feature importance from the same saved run. Importance describes the fitted model; it does not establish a causal effect on developer expertise.
View the saved classification report

Scroll horizontally to see all result columns.

Table 4. Archived test-set results, rounded as printed in the notebook
Target labelPrecisionRecallF1Support
00.510.480.491,537
10.370.390.381,468
20.330.370.351,474
30.550.460.501,470
40.620.690.651,468
51.000.980.991,467
Macro average0.570.560.568,884

For a new predictive study, fit preprocessing on training data only and consider author-level splits. The archived example imputes before splitting and demonstrates a notebook-level split.

Quick Start

Download notebook_metrics.csv to your working directory. Install pandas with pip install pandas, then inspect the data and its schema.

Python · inspect notebook metrics
import pandas as pd

metrics = pd.read_csv("notebook_metrics.csv")
print(metrics.shape)
print(metrics.columns.tolist())
print(metrics.head())
Optional: sample the code-cell file

First download code.csv (3.9 GB) into the same working directory. Then run:

Python · sample code cells
import pandas as pd

for cells in pd.read_csv("code.csv", chunksize=10_000):
    print(cells.head())
    break

The cell CSVs are large; use samples, chunks, or selected columns rather than loading every cell at once. See the repository utilities for aggregation and the example analysis.

BibTeX

Mojtaba Mostafavi Ghahfarokhi, Arash Asgari, Mohammad Abolnejadian, and Abbas Heydarnoori. 2024. DistilKaggle: A Distilled Dataset of Kaggle Jupyter Notebooks. MSR ’24, 647–651.

Paper DOI: 10.1145/3643991.3644882
Dataset DOI: 10.5281/zenodo.10317389

Download BibTeX
@inproceedings{mostafavi-msr2024-DistilKaggle,
  author    = {Mostafavi Ghahfarokhi, Mojtaba and Asgari, Arash and
               Abolnejadian, Mohammad and Heydarnoori, Abbas},
  title     = {{DistilKaggle}: A Distilled Dataset of {Kaggle} {Jupyter} Notebooks},
  booktitle = {Proceedings of the 21st International Conference on Mining Software Repositories},
  series    = {MSR '24},
  year      = {2024},
  pages     = {647--651},
  publisher = {Association for Computing Machinery},
  address   = {New York, NY, USA},
  location  = {Lisbon, Portugal},
  doi       = {10.1145/3643991.3644882},
  url       = {https://doi.org/10.1145/3643991.3644882}
}