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.0.tar.gz (10.8 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.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for danda-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7f0e33db6fc7d75af1388d0074eb97056194a20b2aaaa5afc3a7ad38970ffd44
MD5 708e54fea44d91d99555bad8b5e2112e
BLAKE2b-256 a5f11f8fcacb1f85fc39f8b222fa00079ecd38c32a73e1d37e859e65fd1aab07

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for danda-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a2960fe35eb4248179c00b59af982319b55acf63d7d3f1613e4dcafc95ed0154
MD5 f618dc6c0052ae8adca66815c64393f1
BLAKE2b-256 e88ee273a829d197cebffe4f71bff7d4ef2447b8b7c0fe442548f36719a8266a

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