Datasets:
Dataset Viewer
The dataset viewer is taking too long to fetch the data. Try to refresh this page.
Server-side error
Error code: ClientConnectionError
29K High-Quality Python Docstring Pairs
Author: Michael Hernandez (XxCotHGxX)
License: CC BY 4.0
Cleaned from: XxCotHGxX/242K_Python_Docstring_Pairs
Overview
A curated, high-quality subset of Python function–docstring pairs for use in code documentation generation, docstring completion, and code understanding tasks.
The original 242K dataset was scraped from open-source Python repositories but contained a significant proportion of functions without docstrings (84% of records), trivial stub functions, and boilerplate-only __init__ methods. This cleaned version retains only records with meaningful code bodies and substantive docstrings.
Cleaning Criteria
Records were removed if any of the following applied:
| Criterion | Rationale |
|---|---|
| Docstring absent or < 10 characters | Core requirement for a docstring pair |
Function body is pass, ..., or empty |
Stub functions with no implementation |
| Function body < 20 characters | Trivially short (e.g., return 1) |
__init__ with only self.x = y assignments and no docstring |
Pure boilerplate initializers |
Result: 29,399 retained from 196,220 (85% removed)
Dataset Schema
| Field | Type | Description |
|---|---|---|
function_name |
string | Name of the Python function |
function_body |
string | Complete function body (excluding def line) |
docstring |
string | Extracted docstring (Google, NumPy, or reStructuredText style) |
context |
string | Surrounding class/module context (if available) |
input_text |
string | Structured input combining context and example |
Usage
from datasets import load_dataset
ds = load_dataset("XxCotHGxX/242K_Python_Docstring_Pairs_Cleaned")
print(ds["train"][0])
Intended Use Cases
- Docstring generation: Fine-tune a model to generate docstrings from function bodies
- Code documentation: Evaluate LLM ability to document real Python code
- Code understanding: Use docstrings as natural-language descriptions of function behavior
- Retrieval augmentation: Match natural language queries to code via docstring embeddings
Limitations
- Python only
- Functions sourced from open-source repositories; quality varies by source project
- Docstring style is heterogeneous (Google, NumPy, reStructuredText, plain text)
- No deduplication beyond the quality filters above
- Downloads last month
- 314