Automatic structured summaries of Python objects - DataFrames, arrays, models, and more
Project description
Pretty Little Summary
Automatic structured summaries of Python objects - DataFrames, arrays, models, and more.
Pretty Little Summary automatically generates clean, structured summaries of Python objects. It's perfect for Jupyter notebooks, data exploration, debugging, and understanding complex objects at a glance.
Features
- 🎯 Single function API: Just call
pls.describe(obj) - 📊 40+ type adapters: pandas, numpy, matplotlib, sklearn, pytorch, polars, and more
- 📜 History tracking: Captures Jupyter notebook code context
- 🔌 Extensible: Register custom adapters for your types
- 🛡️ Zero required dependencies: Works with just Python stdlib
- ⚡ Fast: Deterministic summaries with no network calls
Installation
pip install pretty-little-summary
Quick Start
import pretty_little_summary as pls
import pandas as pd
# Create a DataFrame
df = pd.DataFrame({
'product': ['Widget', 'Gadget', 'Doohickey'],
'price': [19.99, 29.99, 39.99],
'quantity': [100, 50, 75]
})
# Get a structured summary
result = pls.describe(df)
print(result.content)
# Output: "pandas.DataFrame | Shape: (3, 3) | Columns: product, price, quantity"
print(result.meta)
# Output: {'object_type': 'pandas.DataFrame', 'shape': (3, 3),
# 'columns': ['product', 'price', 'quantity'], ...}
Supported Types
Pretty Little Summary includes adapters for:
Data Structures:
- pandas (DataFrame, Series)
- polars (DataFrame, LazyFrame)
- numpy (ndarray)
- PyArrow (Table)
- xarray (Dataset, DataArray)
Visualization:
- matplotlib (Figure, Axes)
- altair (Chart)
- plotly (Figure)
- seaborn (Axes)
- bokeh (Figure)
Machine Learning:
- scikit-learn (models, pipelines)
- PyTorch (Tensor, Module)
- TensorFlow (Tensor, Model)
- JAX (Array)
Other:
- Built-in types (list, dict, set, etc.)
- datetime objects
- Pydantic models
- NetworkX graphs
- Regular expressions
- File handles
- And more!
Usage Examples
Basic Types
import pretty_little_summary as pls
# Lists
result = pls.describe([1, 2, 3, 4, 5])
print(result.content)
# "list | Length: 5 | Type: int"
# Dictionaries
result = pls.describe({'name': 'Alice', 'age': 30})
print(result.content)
# "dict | Keys: 2 | Types: str -> int, str -> str"
Data Science Objects
import numpy as np
import pretty_little_summary as pls
# NumPy arrays
arr = np.random.rand(100, 50)
result = pls.describe(arr)
print(result.content)
# "numpy.ndarray | Shape: (100, 50) | dtype: float64"
Jupyter Integration
In Jupyter notebooks, Pretty Little Summary automatically captures the code history:
import pandas as pd
import pretty_little_summary as pls
df = pd.read_csv('data.csv')
df_clean = df.dropna()
df_filtered = df_clean[df_clean['value'] > 100]
result = pls.describe(df_filtered)
print(result.history)
# ['df = pd.read_csv(\'data.csv\')',
# 'df_clean = df.dropna()',
# 'df_filtered = df_clean[df_clean[\'value\'] > 100]']
Optional Dependencies
Pretty Little Summary has zero required dependencies. It works out of the box with Python's standard library.
For specialized type support, install the corresponding library:
# Data science
pip install pretty-little-summary[pandas]
pip install pretty-little-summary[data] # pandas + polars
# Visualization
pip install pretty-little-summary[viz] # matplotlib + altair
# Machine learning
pip install pretty-little-summary[ml] # scikit-learn + pytorch
# Everything
pip install pretty-little-summary[all]
API Reference
describe(obj, name=None)
Generate a structured summary of any Python object.
Args:
obj: Any Python object to analyzename(optional): Variable name for history filtering (auto-detected in Jupyter)
Returns:
Descriptionobject with:content(str): Human-readable summarymeta(dict): Structured metadatahistory(list[str] | None): Code history if in Jupyter
list_available_adapters()
List all currently registered adapters.
Returns:
- list[str]: Names of available adapters
import pretty_little_summary as pls
adapters = pls.list_available_adapters()
print(adapters)
# ['PrimitiveAdapter', 'CollectionsAdapter', 'PandasAdapter', ...]
How It Works
- Type Detection: Automatically selects the best adapter for your object type
- Metadata Extraction: Gathers relevant information (shape, columns, dtypes, etc.)
- Summary Generation: Creates a clean, structured summary
- History Capture: In Jupyter, tracks how the object was created
Custom Adapters
You can register custom adapters for your own types:
from pretty_little_summary.adapters._base import AdapterRegistry
from pretty_little_summary.core import MetaDescription
class MyCustomAdapter:
@staticmethod
def can_handle(obj):
return isinstance(obj, MyCustomType)
@staticmethod
def extract_metadata(obj):
return {
"object_type": "MyCustomType",
"adapter_used": "MyCustomAdapter",
"custom_field": obj.some_property,
}
AdapterRegistry.register(MyCustomAdapter)
Why Pretty Little Summary?
- Debug faster: Quickly understand what's in your variables
- Document better: Auto-generate object descriptions for notebooks
- Share knowledge: Help teammates understand complex data structures
- Explore confidently: Get instant insights into unfamiliar objects
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pretty_little_summary-0.1.0.tar.gz.
File metadata
- Download URL: pretty_little_summary-0.1.0.tar.gz
- Upload date:
- Size: 120.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9e54be21b26a83af1881b685a86f91b3dd5d170a4548a45a3d98c89ecc6f34f
|
|
| MD5 |
d77624aadfe2c104e3457b6b5d758190
|
|
| BLAKE2b-256 |
434f600824742d41dd1fdf53ecc22f638976ec183a17393f4c6f84a0e18c8b8d
|
File details
Details for the file pretty_little_summary-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pretty_little_summary-0.1.0-py3-none-any.whl
- Upload date:
- Size: 69.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18598343738ca8102f8d9f11930388ac114d011178542f0ce2b4a3ad93f57a64
|
|
| MD5 |
997efddbbee55a1a012c15ac5ef12350
|
|
| BLAKE2b-256 |
b04df86e06723eb0b65eed80e2b775ef1b97a0b4e301d36016d67939413e825b
|