Skip to main content

Polars minimal data profiler.

Project description

Polars minimal data profiler

Overview

The pldmp package provides an easy way to perform data profiling using the Polars library. It analyzes datasets to generate various statistical summaries and insights, helping users understand the structure and quality of their data.

Features

  • Supports a variety of data types, including numeric, string, and datetime.
  • Computes key statistical metrics such as mean, median, standard deviation, and percentiles.
  • Detects missing values, empty fields, and string token distributions.
  • Provides both a Python and a command-line interface (CLI) for easy usage.

Installation

pip install plmdp

Usage

Python Example

from pathlib import Path
from pprint import pprint
import polars as pl
from plmdp import Profiler

if __name__ == "__main__":
    datafile_path = Path(__file__).resolve().parent / "data.csv"
    data: pl.DataFrame = pl.read_csv(datafile_path, separator=";")
    results = Profiler().run_profiling(data)
    pprint(results)

Example output

ProfilerOutput(rows_count=20,
               column_count=3,
               ignored_columns=[],
               dataframe_size=745,
               columns=[ColumnData(name='comment',
                                   type='String',
                                   metrics=StringProfile(nulls_count=0,
                                                         min_length=14,
                                                         max_length=27,
                                                         avg_length=19.25,
                                                         median_length=19.0,
                                                         min_token_count=2,
                                                         max_token_count=4,
                                                         avg_token_count=2.35,
                                                         median_token_count=2.0,
                                                         empty_or_whitespace_count=0)),
                        ColumnData(name='dob',
                                   type='String',
                                   metrics=StringProfile(nulls_count=0,
                                                         min_length=10,
                                                         max_length=10,
                                                         avg_length=10.0,
                                                         median_length=10.0,
                                                         min_token_count=1,
                                                         max_token_count=1,
                                                         avg_token_count=1.0,
                                                         median_token_count=1.0,
                                                         empty_or_whitespace_count=0)),
                        ColumnData(name='sales',
                                   type='Int64',
                                   metrics=NumericProfile(nulls_count=0,
                                                          mean=181.5,
                                                          median=185.0,
                                                          std=78.42,
                                                          min=50,
                                                          max=320,
                                                          percentile25=120.0,
                                                          percentile50=190.0,
                                                          percentile75=230.0))],
               created_at=datetime.datetime(2025, 2, 18, 14, 6, 29, 574191, tzinfo=datetime.timezone.utc))

CLI Example

#!/bin/bash

DATA_PATH="$(pwd)/data.csv"
SCHEMA='{"comment": "String", "dob": "Date", "sales": "Float32"}'
LOADER_KWARGS='{"separator":";"}'
FORMATTER='json'

plmdp --path "$DATA_PATH" --schema="$SCHEMA" --kwargs="$LOADER_KWARGS" --formatter="$FORMATTER"

Example output

{
  "rows_count": 20,
  "column_count": 3,
  "ignored_columns": [],
  "dataframe_size": 545,
  "columns": [
    {
      "name": "comment",
      "type": "String",
      "metrics": {
        "nulls_count": 0,
        "min_length": 14,
        "max_length": 27,
        "avg_length": 19.25,
        "median_length": 19.0,
        "min_token_count": 2,
        "max_token_count": 4,
        "avg_token_count": 2.35,
        "median_token_count": 2.0,
        "empty_or_whitespace_count": 0
      }
    },
    {
      "name": "dob",
      "type": "Date",
      "metrics": {
        "nulls_count": 0,
        "min": "1973-09-19",
        "max": "1999-08-29"
      }
    },
    {
      "name": "sales",
      "type": "Float32",
      "metrics": {
        "nulls_count": 0,
        "mean": 181.5,
        "median": 185.0,
        "std": 78.42,
        "min": 50.0,
        "max": 320.0,
        "percentile25": 120.0,
        "percentile50": 190.0,
        "percentile75": 230.0
      }
    }
  ],
  "created_at": "2025-02-18 14:07:23.736730+00:00"
}

Supported Data Types

The package supports the following Polars data types:

  • Numeric: Float32, Float64, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, Decimal
  • String: String, Categorical
  • Date/Time: Date, Datetime
  • Others: Boolean

Metrics Computed

  • String Profile: Minimum/maximum/average string length, token counts, empty or whitespace count.
  • Numeric Profile: Mean, median, standard deviation, min/max values, and percentiles.
  • Date/Datetime Profile: Minimum and maximum values.
  • Base Profile: Null values count.

Project details


Download files

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

Source Distribution

plmdp-0.1.5.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

plmdp-0.1.5-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file plmdp-0.1.5.tar.gz.

File metadata

  • Download URL: plmdp-0.1.5.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.4

File hashes

Hashes for plmdp-0.1.5.tar.gz
Algorithm Hash digest
SHA256 ad6fc0e466ba0601db79f2079f3557c2b480d0d5b138221dcdaf3d62a3293a84
MD5 4137b2b32f40c72b98a01a4e5be79622
BLAKE2b-256 62193403f1d4804a8cc5fc5d26a4aae6ebbe6a3873f92266847e04e1cff2db1c

See more details on using hashes here.

File details

Details for the file plmdp-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: plmdp-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.4

File hashes

Hashes for plmdp-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3b55fd691daa18380a9d7e43a35b8c65a88134a0be7a2f925278bf0ed56fa337
MD5 fb0387eebb73f9c04321b67adcf2de77
BLAKE2b-256 55d9e4f499390a1a4dbd9931095e68b88178e0be506e984c89a61b086937ecd2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page