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.1.tar.gz (20.4 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.1-py3-none-any.whl (29.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nullsweep-0.1.1.tar.gz
  • Upload date:
  • Size: 20.4 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.1.tar.gz
Algorithm Hash digest
SHA256 a3e0371d85e5ba0784a555bd38ee3d9df085262d82d6c188755cd50f51136b4e
MD5 40ede7e8528ebe3e792091b18a5ef9a4
BLAKE2b-256 fbb2b6f5ab71936ab350969b71c97b4fe1f0079154503f212f3ff79756475741

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nullsweep-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 29.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4690a6ee6c981c3ad4c0a5cd00135a6a49f9a05193b3af6a08691e72d0e1a99c
MD5 5547e30a8e0a352cc5be0d5bb08f0801
BLAKE2b-256 79de4169ee6fc477ca54885888c43a2b426a9e2193154f432a2e2daf544cfe19

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