Skip to main content

A data wrangling library

Project description

PyBandiger

PyBandiger is a Python library for preprocessing data, including cleaning, encoding, scaling, and transforming date columns. It is designed to simplify the data wrangling process for machine learning tasks.

Installation

You can install PyBandiger using pip:

pip install pybandiger

Usage

Importing the Library

from pybandiger import PyBandiger

Creating an Instance

pb = PyBandiger()

Cleaning Data

The clean method fills missing values in categorical columns with 'Missing' and in numerical columns with the mean of the column.

cleaned_data = pb.clean(data)

Parameters:

  • data (pd.DataFrame): The input DataFrame to be cleaned.

Encoding and Scaling Data

The EncodeAndScale_fit method encodes categorical columns using LabelEncoder and scales numerical columns using StandardScaler.

encoded_scaled_data = pb.EncodeAndScale_fit(cleaned_data)

Parameters:

  • data (pd.DataFrame): The input DataFrame to be encoded and scaled.

The EncodeAndScale_transform method transforms new data using the previously fitted encoders and scaler.

new_encoded_scaled_data = pb.EncodeAndScale_transform(new_data)

Parameters:

  • data (pd.DataFrame): The new DataFrame to be transformed using the fitted encoders and scaler.

Transforming Date Columns

The time_transform method extracts year, month, day, and day of the week from a date column and drops the original date column.

transformed_data = pb.time_transform(data, date_col='date')

Parameters:

  • data (pd.DataFrame): The input DataFrame containing the date column.
  • date_col (str): The name of the date column to be transformed. Default is 'date'.
  • prefix (str): The prefix to add to the new date-related columns. Default is ''.

Example

import pandas as pd
from pybandiger import PyBandiger

# Sample data
data = pd.DataFrame({
    'category': ['A', 'B', 'A', None],
    'value': [1.0, 2.5, None, 4.0],
    'date': ['2021-01-01', '2021-02-01', '2021-03-01', '2021-04-01']
})

# Create an instance of PyBandiger
pb = PyBandiger()

# Clean the data
cleaned_data = pb.clean(data)

# Encode and scale the data
encoded_scaled_data = pb.EncodeAndScale_fit(cleaned_data)

# Transform date columns
transformed_data = pb.time_transform(cleaned_data)

print(encoded_scaled_data)
print(transformed_data)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

Author

Lansari Fedi - lansarifedi7@gmail.com

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

pybandiger-0.1.9.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

pybandiger-0.1.9-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file pybandiger-0.1.9.tar.gz.

File metadata

  • Download URL: pybandiger-0.1.9.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.13

File hashes

Hashes for pybandiger-0.1.9.tar.gz
Algorithm Hash digest
SHA256 51c2190031fed91deee8f4a4309106e31845c4db913cfc6c86c928203e4ac889
MD5 353386fb9d52b6bddfef559c4a493fa8
BLAKE2b-256 40f639fb778c0609c803e43b87f033bf6ea6096c19609a2770b2408bb60c5a59

See more details on using hashes here.

File details

Details for the file pybandiger-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: pybandiger-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.13

File hashes

Hashes for pybandiger-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 37f58837065be1cd7a7053851b3ff30ba7919e2becda3f32071dacdfc241dadf
MD5 11b4f8b626d5456ac65c09b924e9afb0
BLAKE2b-256 8750cdd753609844950db423cd72d081e944b4bba572280bf48d33be06bd73ae

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