Advanced data cleaning built on top of Pandas
Project description
BambooChute: Advanced Data Cleaning for Pandas
BambooChute is a comprehensive Python package built on top of Pandas, dedicated to simplifying and enhancing data cleaning workflows. With a wide range of functionality for managing missing data, outlier detection, data validation, and more, BambooChute provides an efficient and user-friendly API for complex data cleaning processes.
Table of Contents
Features
- Versatile Data Loading: Load data from multiple formats (CSV, Excel, JSON, DataFrames).
- Advanced Missing Data Handling: Use a variety of imputation strategies (mean, median, KNN, custom) and drop functions.
- Flexible Outlier Detection & Removal: Detect outliers with Z-score, IQR, Isolation Forest, and DBSCAN, with customizable removal methods.
- Categorical Data Encoding: Efficiently convert and encode categorical data with options for one-hot encoding, frequency encoding, and more.
- Robust Date Handling: Convert dates, extract parts, manage date ranges, and handle invalid dates.
- Data Validation Tools: Validate data types, range of values, and consistency.
- Duplicate Management: Identify, mark, merge, and handle near-duplicates using fuzzy matching.
- Consistent Data Formatting: Clean string data by trimming whitespace, standardizing cases, and removing special characters.
- In-depth Data Profiling: Generate summary reports and detect trends within data.
Installation
Install BambooChute via pip:
pip install BambooChute
Ensure dependencies from requirements.txt are installed:
pip install -r requirements.txt
Getting Started
Here’s a quick start to load and clean data:
import pandas as pd
from BambooChute import Bamboo
# Load data
data = pd.read_csv('data.csv')
# Initialize Bamboo
bamboo = Bamboo(data)
# Preview data
print(bamboo.preview_data())
# Handle missing data
bamboo.impute_missing(strategy='mean')
# Detect and remove outliers
bamboo.detect_outliers_zscore(threshold=3)
# Export cleaned data
bamboo.export_data('cleaned_data.csv')
Functionality Overview
Loading Data
Bamboo supports loading data from CSV, Excel, JSON, and directly from Pandas DataFrames.
# Load data from various formats
bamboo = Bamboo('data.csv')
bamboo = Bamboo(df)
Handling Missing Data
Various strategies allow for flexibility in handling missing values.
# Basic imputation
bamboo.impute_missing(strategy='mean')
# Custom filling
bamboo.fill_with_custom(lambda x: 'default' if x is None else x)
# Drop missing data
bamboo.drop_missing(axis=0, how='any')
Outlier Detection and Removal
Multiple methods for outlier detection, including Isolation Forest, IQR, and Z-score.
# Detect outliers
outliers = bamboo.detect_outliers_zscore(threshold=3)
# Remove outliers using specific methods
bamboo.remove_outliers(method='iqr')
bamboo.remove_outliers_isolation_forest(contamination=0.1)
Categorical Data Processing
Easily encode and manipulate categorical data.
# Convert columns to categorical type
bamboo.convert_to_categorical(['column'])
# Encode categorical data with one-hot or label encoding
bamboo.encode_categorical(method='onehot')
bamboo.encode_frequency()
Date Handling and Transformation
Comprehensive support for managing date data.
# Convert columns to datetime
bamboo.convert_to_datetime(['date_column'])
# Extract specific date parts (e.g., year, month)
bamboo.extract_date_parts('date_column', parts=['year', 'month'])
# Detect missing intervals in time series
missing_dates = bamboo.detect_time_gaps('date_column')
Data Type Validation
Ensure data types are consistent and enforce specific types across columns.
# Check for data type consistency
consistency = bamboo.check_dtype_consistency()
# Convert columns to specific data types
bamboo.convert_column_types({'age': 'int64'})
Duplicate Management
Handle duplicates efficiently, with support for merging and marking.
# Identify duplicates
duplicates = bamboo.identify_duplicates(subset=['name'])
# Drop duplicates, keeping specific occurrences
bamboo.drop_duplicates(keep='first')
# Handle near-duplicates using fuzzy matching
bamboo.handle_near_duplicates(column='name', threshold=0.8)
Data Formatting
Various utilities to clean and standardize data formatting.
# Trim whitespace in string columns
bamboo.trim_whitespace()
# Standardize case in text
bamboo.standardize_case(case='title')
# Remove special characters
bamboo.remove_special_characters(columns=['column'])
Data Profiling
Generate data profiling reports for better insight into dataset structure and quality.
# Generate profiling summary
summary = bamboo.generate_summary_report()
Testing
To run unit tests:
python -m unittest discover tests
Contributing
To contribute:
- Fork the repository.
- Create a new branch.
- Make changes and submit a pull request.
License
Licensed under the MIT License.
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
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
File details
Details for the file BambooChute-1.0.3.tar.gz.
File metadata
- Download URL: BambooChute-1.0.3.tar.gz
- Upload date:
- Size: 26.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cb96b80d5e131f277e2b0c93edec5441b5c09fe76633ec604ad8c400e09065b
|
|
| MD5 |
0e39177c41f40714ed3ad261d9b4761b
|
|
| BLAKE2b-256 |
eef9caec328c6b52bb6eefd3a142f96993899817f0df790f4a9b7435931e6be6
|
File details
Details for the file BambooChute-1.0.3-py3-none-any.whl.
File metadata
- Download URL: BambooChute-1.0.3-py3-none-any.whl
- Upload date:
- Size: 23.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb0bb6620e368e200fa83af0d7b03d3bf19786f58ae9d728ddeeea60291c9dd2
|
|
| MD5 |
1fba5da9b8cbd9597c257e58cdb6e560
|
|
| BLAKE2b-256 |
1882b5d83bf5b4d0c8aeec9ada559fd2d941ad08d18066591aab6394c0ed80dc
|