Skip to main content

Automatically prepare pandas DataFrames for analysis.

Project description

danda

Automatically prepare pandas DataFrames for analysis. Danda automatically:

  • removes empty rows
  • removes empty columns
  • trims whitespace
  • detects dates
  • detects booleans
  • detects categorical columns
  • optimizes memory
  • generates a cleaning report

A library that aims to be a drop-in replacement for pd.read_csv() and automatically:

  • detects column types
  • converts low-cardinality strings to category
  • parses dates
  • optimizes integer/float dtypes
  • trims whitespace
  • standardizes missing values ("", "NA", "N/A", "null", etc.)
  • removes empty rows and columns
  • optionally generates a cleaning report
import danda as dg

df = dg.read_csv("sales.csv")
df = dg.read_excel("sales.xlsx")
df = dg.read_parquet("sales.parquet")

Installation

pip install danda

Usage

import pandas as pd
import danda

df = pd.read_csv("employees.csv")

clean_df = df.dg.clean()

What happens automatically

  • Remove empty rows
  • Remove empty columns
  • Strip whitespace [" John ", " John", "John "] -> John
  • Normalize missing values ["", " ", "N/A", "NULL", "None", "-"] -> Nan
  • Detect dates 2025-01-01->datetime64[ns]
  • Detect booleans [Yes , No , TRUE , FALSE ,0, 1] -> bool
  • Detect categorical columns unique values < 20 or unique ratio < 15%
  • Optimize integer types int64 -> int8
  • Detect IDs: do not do these [CustomerID , ZipCode , PostalCode, Phone]
  • Memory optimization: Show users the improvement. Memory before : 95 MB, Memory after : 21 MB, Reduction : 77.9%
  • Cleaning report:

Features

  • Validation: WARNING Column Age: 12 invalid values , converted to NaN
  • Profiling: Rows 145,000 Columns 24 Missing 3.2% Duplicates 512 Memory 18 MB Categorical 7 Numeric 10 Datetime 3
  • suggestions: Suggestions CustomerID Looks like an ID column. Convert to string? [Y/n]
  • Plugin system
dg.read_csv(
    "sales.csv",
    plugins=[
        dg.TrimWhitespace(),
        dg.ParseDates(),
        dg.RemoveDuplicates(),
        dg.NormalizeMissing(),
    ],
)
  • Pandas accessor
import pandas as pd
import dataforge

df = pd.read_csv("sales.csv")

df.dg.clean()

df.dg.profile()

df.dg.optimize()

df.dg.report()

Normalize missing values

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

danda-0.1.2.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

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

danda-0.1.2-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file danda-0.1.2.tar.gz.

File metadata

  • Download URL: danda-0.1.2.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for danda-0.1.2.tar.gz
Algorithm Hash digest
SHA256 bf61d43325c453b06a69a7ded7aff9dc37aa2e42cdc21e3f34d152a49fd59fb4
MD5 c90cefda34f0a69f3056a35814bcec13
BLAKE2b-256 f616b2160090ef7cf8429ae708d26a087ca823c964213550a4eed7072d7397af

See more details on using hashes here.

File details

Details for the file danda-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: danda-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for danda-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2f608d7af9774b942b50599dc3d1ec4f288e80ca44f93f139e5f13794c49e914
MD5 a6e3abd8793b79c13799f239860cc65c
BLAKE2b-256 b0357f0589d20d6ad3319c91fe7d855f54a3d0a06bdf48ba6928bd7cfea24d86

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