A package for data cleaning and feature engineering
Project description
DataPrepToolkit
A package for data cleaning, feature engineering, and visualizing data properties.
Installation
You can install the package using pip:
pip install git+https://github.com/CoskunErden/DataPrepToolkit.git
Usage
Data Cleaning and Visualization
Showing Missing Values
from DataPrepToolkit.data_cleaning import DataCleaner import pandas as pd
Sample dataframe
df = pd.DataFrame({ 'A': [1, 2, None, 4], 'B': [None, None, None, None], 'C': [1, 2, 3, 4] })
Initialize DataCleaner
cleaner = DataCleaner(df)
Show missing values heatmap
cleaner.show_missing_values()
Plot percentage of missing values
cleaner.missing_values_percentage()
Listing Features
List categorical and numerical features
categorical_features, numerical_features = cleaner.list_features() print("Categorical Features:", categorical_features) print("Numerical Features:", numerical_features)
Summary Statistics
Summary statistics for numerical features
summary_stats = cleaner.summary_statistics() print(summary_stats)
Count Categorical Features
Counts and unique values for categorical features
cat_counts = cleaner.count_categorical_features() print(cat_counts) Removing and Filling Missing Values
Remove columns with more than 50% missing values
cleaned_df = cleaner.remove_missing_values(threshold=0.5)
Fill missing values using mean strategy
filled_df = cleaner.fill_missing_values(strategy='mean') Feature Engineering and Visualization Plotting Feature Distributions
from DataPrepToolkit.feature_engineering import FeatureEngineer import pandas as pd
Sample dataframe
df = pd.DataFrame({'A': ['a', 'b', 'a', 'c'], 'B': [1, 2, 3, 4]})
Initialize FeatureEngineer
engineer = FeatureEngineer(df)
Plot feature distributions
engineer.plot_feature_distribution(columns=['A', 'B']) Plotting Correlation Heatmap
Plot correlation heatmap
engineer.plot_correlation_heatmap() Encoding Categorical Features and Normalizing Features
Encode categorical features without dropping the first column
encoded_df = engineer.encode_categorical(columns=['A'])
Encode categorical features with dropping the first column
encoded_df_drop_first = engineer.encode_categorical(columns=['A'], drop_first=True)
Normalize features
normalized_df = engineer.normalize_features(columns=['B']) Utility Functions Loading and Saving Data
from DataPrepToolkit.utils import load_data, save_data import pandas as pd
Load data from a CSV file
df = load_data('data.csv')
Save dataframe to a CSV file
save_data(df, 'data_saved.csv')
Logging
from DataPrepToolkit.utils import setup_logging, log
Set up logging
setup_logging('app.log')
Log messages
log('This is an info message.') log('This is a warning message.', level='warning') log('This is an error message.', level='error')
Calculating Missing Values Percentage
from DataPrepToolkit.utils import calculate_missing_values_percentage
Sample dataframe
df = pd.DataFrame({ 'A': [1, 2, None, 4], 'B': [None, None, None, None], 'C': [1, 2, 3, 4] })
Calculate missing values percentage
missing_percentage = calculate_missing_values_percentage(df) print(missing_percentage)
License This project is licensed under the MIT License - see the LICENSE.txt file for details.
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 Distributions
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 DataPrepPro-0.2.0-py3-none-any.whl.
File metadata
- Download URL: DataPrepPro-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71868a03b2c5b804b6c5999a7a62e198b55601068a8b9c4fc79630c103c880df
|
|
| MD5 |
da244682469634770cc0e6368a41efde
|
|
| BLAKE2b-256 |
021482328bc5d0e0de94a71169147ede5722132a7639557f41f7ac94738d8118
|