Skip to main content

A comprehensive Python package for managing and analyzing missing data in pandas DataFrames, starting with detection and expanding to complete handling.

Project description

NullSweep

NullSweep is a Python library designed for detecting and handling patterns of missing data in pandas DataFrames. This tool provides a simple API to identify global missing data patterns across the entire dataset, patterns related to specific features within the dataset, and to impute missing values using various strategies.

Features

  • Detect global patterns of missing data in a DataFrame.
  • Detect missing data patterns in specific features/columns of a DataFrame.
  • Impute missing data in specific features or across the entire DataFrame using a variety of strategies.
  • Utilizes a modular approach with different pattern detection and imputation strategies.

Installation

Install NullSweep using pip:

pip install nullsweep

Usage

Detect Global Patterns

To detect global missing data patterns in a pandas DataFrame:

import pandas as pd
from nullsweep import detect_global_pattern

# Sample DataFrame
data = {'A': [1, 2, None], 'B': [None, 2, 3]}
df = pd.DataFrame(data)

# Detect global missing data pattern
pattern, details = detect_global_pattern(df)
print("Detected Pattern:", pattern)
print("Details:", details)

Detect Feature-Specific Patterns

To detect missing data patterns in a specific feature of a pandas DataFrame:

import pandas as pd
from nullsweep import detect_feature_pattern

# Sample DataFrame
data = {'A': [1, None, 3], 'B': [4, 5, 6]}
df = pd.DataFrame(data)

# Detect feature-specific missing data pattern
feature_name = 'A'
pattern, details = detect_feature_pattern(df, feature_name)
print("Detected Pattern:", pattern)
print("Details:", details)

Impute Missing Values

To impute missing values in a specific feature or across the entire DataFrame:

import pandas as pd
import nullsweep as ns

# Sample DataFrame
data = {
    'Age': [25, 30, None, 35, 40],
    'Gender': ['Male', 'Female', None, 'Female', 'Male']
}
df = pd.DataFrame(data)

# Impute missing values in 'Age' using mean
df = ns.impute_nulls(df, feature='Age', strategy='mean')

# Impute missing values in 'Gender' using the most frequent value
df = ns.impute_nulls(df, feature='Gender', strategy='most_frequent')

# Impute missing values in 'Age' using linear interpolation
df = ns.impute_nulls(df, feature='Age', strategy='interpolate')

# Impute missing values for multiple features
df = ns.impute_nulls(df, feature=['Age', 'Gender'], strategy='interpolate')

# Impute all features with missing values using automatic strategy detection
df = ns.impute_nulls(df)

Contributing

Contributions are welcome! Please feel free to submit pull requests, open issues, or suggest improvements.

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

nullsweep-0.1.0.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

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

nullsweep-0.1.0-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nullsweep-0.1.0.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for nullsweep-0.1.0.tar.gz
Algorithm Hash digest
SHA256 01d93fc8f1c3a745051b64aaa9f4b038445e3fcd57e1c18c5ed12430cc2c9ec3
MD5 7c787f25aa285ed7653244006c2e3405
BLAKE2b-256 53a48b31ec3f3ba122ea31b5e6f3e30a5c70a19a18b6c4fb14be5755f2c410df

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nullsweep-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for nullsweep-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d51b9c7ab6ec63ee0f53ea920deea3f9bb42facc3080e0d16db785150d6b2c5
MD5 5068761f3913f92e3706684e265865ac
BLAKE2b-256 731b0a89cce98af5058317ba2a06b346d69a8df4d8fbdaab17685fc6e870af5c

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