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
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
danda-0.1.1a4.tar.gz
(10.7 kB
view details)
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
danda-0.1.1a4-py3-none-any.whl
(12.4 kB
view details)
File details
Details for the file danda-0.1.1a4.tar.gz.
File metadata
- Download URL: danda-0.1.1a4.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11779e475c3acc669fd573ac598d743974d806e9ae6cbc95336e270d8dc206a2
|
|
| MD5 |
d102fb98a6b78323234636b52da96f7b
|
|
| BLAKE2b-256 |
a72938536fec021d54970da0bab3cdc011f4aded3b1ef987a3f866e5c25bca09
|
File details
Details for the file danda-0.1.1a4-py3-none-any.whl.
File metadata
- Download URL: danda-0.1.1a4-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
560a3e6023ca18ede5913e39c786f83525e828bec772c6d7e48de6ad17615877
|
|
| MD5 |
6818add0bc116c9a42f7dd75e1141916
|
|
| BLAKE2b-256 |
232d86686f1517f48e8f88e2a6d619f8c40eb6ab1c4a2e58b3551f0632a27be4
|