Skip to main content

🔬 Polarscope

PyPI PyPI - Python Version License: MIT

Simple data inspection tools for Polars 🐻‍❄️

Polarscope is a basic data analysis library for Polars DataFrames. It provides an xray() function for data inspection and some plotting utilities. Still early in development with more features planned.


✨ Current Features

🔬 Data Inspection (xray)

  • Summary statistics for numeric columns by default; include='all' covers every dtype.
  • Rich string statistics for String/Categorical/Enum columns: top value and frequency, min/median/avg/max length, mode share, top-3 values, and value samples.
  • Boolean columns analyzed as 0/1 (Mean = share of True); temporal columns report earliest/latest timestamps.
  • Optional expanded output (expanded=True) with normality/uniformity tests, outlier metrics, usability flags, and correlation details.
  • Inline distribution nanoplots and per-column data-quality flags.
  • Great Tables output (great_tables=True) or plain Polars DataFrame output (great_tables=False).

📊 Built-in Datasets

  • Three datasets ship with the package: ps.titanic(), ps.diabetes(), and ps.cardio() (70k-row health records).
  • Also available via from polarscope.datasets import titanic, diabetes, cardio, with loader helpers and dataset metadata.

🧹 Cleaning & Optimization (fix)

  • ps.fix(df) cleans and optimizes in one call: column renaming (case="snake"/"camel"/"pascal"/"kebab"/"upper"/"lower"), whitespace stripping (empty strings → null), dtype shrinking, and empty-column removal — with a compact report of what changed.
  • Opt-in extras: drop_duplicate_rows, missing_threshold, drop_constant_columns, outliers="iqr"/"zscore".
  • Lossless by default: anything that removes or alters data must be switched on explicitly.
  • Building blocks also available standalone: clean_column_names, convert_datatypes, drop_missing.

📈 Plots

  • Correlation/missing/distribution/categorical plots (plotly or altair backends)

✅ Polars-Only Data Handling

  • Data handling is implemented with Polars.
  • No Pandas is required for core data processing.

🚀 Quick Start

Installation

pip install polarscope

Optional extras:

pip install "polarscope[altair]"   # optional Altair plotting backend
pip install "polarscope[plotly]"   # Kaleido support for static Plotly images
pip install "polarscope[scipy]"    # statistical tests
pip install "polarscope[all]"      # all optional features
pip install "polarscope[dev]"      # pytest + coverage tools

Plotly is included in the base installation and is the default plotting backend.

Basic Usage

import polars as pl
import polarscope as ps

# Use a built-in dataset or load your own
df = ps.titanic()          # also: ps.diabetes(), ps.cardio()
# df = pl.read_csv("your_data.csv")

# Get basic data summary (all column types)
ps.xray(df, include="all")

# More detailed analysis
ps.xray(df, include="all", expanded=True)

# Custom title and correlation analysis
ps.xray(df, title="My Data Analysis", corr_target="Survived")

# Clean & optimize in one call (snake_case names, trimmed strings,
# shrunk dtypes, empty columns dropped - with a report)
df = ps.fix(df)

# Or opt in to deeper cleaning
df = ps.fix(df, case="camel", drop_duplicate_rows=True, missing_threshold=0.9)

Common xray() Options

ps.xray(
    df,
    include="all",                # include all columns (not only numeric)
    expanded=True,                # additional stats/tests/quality fields
    corr_target="column_name",    # correlation against target column
    outlier_method="iqr",         # or "percentile"/"zscore"
    percentiles=[0.1, 0.5, 0.9],  # custom percentiles
    decimals=2,
    great_tables=False            # return Polars DataFrame
)

🩺 Troubleshooting

Notebook still uses old code

If you changed source code locally but notebooks still show old behavior, reinstall in the same interpreter and restart kernel:

import sys, subprocess
subprocess.check_call([sys.executable, "-m", "pip", "install", "-e", "/path/to/polarscope"])

ValueError: Only the x-axis of a nanoplot allows strings

This comes from Great Tables nanoplot rendering when unsupported payloads reach the renderer. Update to latest local source and restart kernel.


🤝 Contributing

This is a small project, but contributions are welcome! Feel free to report bugs or suggest improvements.


📄 License

MIT License - see LICENSE file for details.


🙏 Acknowledgments

Inspired by klib and built with great_tables.


🔬 A simple tool for basic Polars data inspection.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polarscope-1.9.1.tar.gz (530.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polarscope-1.9.1-py3-none-any.whl (530.7 kB view details)

Uploaded Python 3

File details

Details for the file polarscope-1.9.1.tar.gz.

File metadata

  • Download URL: polarscope-1.9.1.tar.gz
  • Upload date:
  • Size: 530.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for polarscope-1.9.1.tar.gz
Algorithm Hash digest
SHA256 dffbe635b7c1024fecf4bb6b090b07a3a36df9c292e9b00209aa0935d0c262bf
MD5 58538f659284fac71204dba8b71de12e
BLAKE2b-256 48f59174602afba8b86cd3c2a8e5ba7100c319db4dfb80df7cf9670d9baef3bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for polarscope-1.9.1.tar.gz:

Publisher: publish.yml on pytoned/polarscope

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polarscope-1.9.1-py3-none-any.whl.

File metadata

  • Download URL: polarscope-1.9.1-py3-none-any.whl
  • Upload date:
  • Size: 530.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for polarscope-1.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c6ab425c10604dfed5a03eac6e7f430bb3257ce66779c59e8b0c65427656f42a
MD5 5559f577dac8b89f2c39846929fdf6cb
BLAKE2b-256 b6f64cf6ae76c33ecd6fe349d017d2c8ef3f2680e2b306c7f5d17baf64c41b0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for polarscope-1.9.1-py3-none-any.whl:

Publisher: publish.yml on pytoned/polarscope

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.9.6

2 files

1.9.5

2 files

1.9.4

2 files

1.9.2

2 files

This release

1.9.1 This release

2 files

1.9.0

2 files

1.7.0

2 files

1.6.1

2 files

1.5.1

2 files

1.5.0

2 files

1.4.7

2 files

1.4.5

2 files

1.4.2

2 files

1.4.1

2 files

1.4.0

2 files

1.3.14

2 files

1.3.4

2 files

1.3.3

2 files

1.3.2

2 files

1.3.1

2 files

1.3.0

2 files

1.2.0

2 files

1.1.4

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page