Skip to main content

Data Preprocessing fns

Project description

Installation

pip install dsfns

FNS Package

FUNCTION DESCRIPTIONS

  1. Outlier_IQR(df, columns) Identifies and handles outliers in the specified columns using the Interquartile Range (IQR) method. Parameters:

    • df: DataFrame — The input data in which outliers will be detected.
    • columns: list — List of column names in which outliers need to be identified.
  2. Outlier_Winsorizer(df, column, capping_method='iqr') Applies Winsorization to cap outliers in the specified column using either IQR or other capping methods. Parameters:

    • df: DataFrame — The input data to apply Winsorization.
    • column: str — The name of the column to apply the Winsorization to.
    • capping_method: str, default 'iqr' — Method used to define the outlier thresholds (options: 'iqr' , std, 'quantiles' or 'mad').
  3. Outlier_Clip(df, columns) Clips extreme values to a predefined threshold in the specified columns, effectively handling outliers. Parameters:

    • df: DataFrame — The input data to clip outliers from.
    • columns: list — List of columns in which to clip the outliers.
  4. MissingVal_Repl(df, columns, type='mean') Replaces missing values in the specified columns using a chosen method. Parameters:

    • df: DataFrame — The input data in which missing values will be replaced.
    • columns: list — List of column names where missing values need to be replaced.
    • type: str, default 'mean' — The method used for replacement ('mean', 'median', or mode)
  5. MissingVal_Imputer(df,columns,strategy='mean') The MissingVal_Imputer function is designed to handle missing values in specified columns of a pandas DataFrame using different imputation strategies. It replaces missing values (NaN) with appropriate values based on the chosen strategy. Parameters:

    • df (pandas.DataFrame): The input DataFrame where missing values need to be imputed.
    • columns (list): A list of column names where missing value imputation is to be applied.
    • strategy (str, default='mean'):The strategy for imputing missing values. Supported values: 'mean': Replaces missing values with the mean of the column. 'median': Replaces missing values with the median of the column. 'mode': Replaces missing values with the most frequent value in the column (converted to 'most_frequent' internally).
  6. MissingVal_Fillna(df) Identifies and returns all rows in the DataFrame that contain missing values with mean for numeric columns and mode (with index[0]) for object. Parameters:

    • df: DataFrame — The input data to check for missing values.

VERSION 1.3

  1. outlierColumns(df) Returns a list of columns that contain outliers based on IQR. Parameters:

    • df: DataFrame — The input data to check for outliers.
  2. outlierCount(df, columns) Counts the number of outliers in the specified columns. Parameters:

    • df: DataFrame — The input data to count outliers in.
    • columns: list — List of columns to check for outliers.
  3. highFrequency(df, perc=0.5) Identifies and returns columns where more than the given percentage (default 70%) of values are identical, typically used to detect low-variance or high-frequency columns. Parameters:

    • df: DataFrame — The input data to identify high-frequency columns.
    • perc: float, default 0.5 — The percentage threshold for identifying high-frequency columns.

VERSION 1.4

  1. Encoding(df, method='label') Encodes categorical columns into numeric labels for compatibility with machine learning algorithms. Parameters:

    • df: A Pandas DataFrame containing the dataset.
    • method: 'label' for label encoding OR 'onehot' for OneHotEncoding
  2. Scaler(df, method='minmax') Scales numerical data for better performance during machine learning model training. Parameters:

    • df: A Pandas DataFrame containing numeric data.
    • method: Specifies the scaling technique to use. Options are: 'minmax' (default): Rescales data to a range of 0 to 1. 'standard': Standardizes data to have a mean of 0 and a standard deviation of 1. 'robust': Scales data using the median and interquartile range, making it robust to outliers.

VERSION 1.5

General code fixes

VERSION 1.6

Redundant Code removed

VERSION 1.7 and 1.8

General code fixes

VERSION 1.9

  1. Outlier_MMM(df, columns, type='median') This function is designed to identify and handle outliers in the specified columns of a given DataFrame. It uses the Interquartile Range (IQR) method to determine outliers and replaces the outliers with a user-defined statistic (mean, median, or mode).

    Parameters: df (DataFrame): The input pandas DataFrame that contains the data to be processed. columns (list of str): A list of column names in the DataFrame where outlier handling should be applied. type (str, optional): The statistic used to replace the outliers. It can be one of 'mean', 'median', or 'mode'. The default is 'median'.

  2. LowVarianceCols(df) This function detects columns in a DataFrame with very low variance (i.e., columns where the values are almost constant or do not vary much). Columns with zero variance are identified as low-variance columns. Returns a list of column names that have low variance (IQR = 0)

    Parameters: df (DataFrame): The input pandas DataFrame for which low variance columns need to be identified. Method:

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

dsfns-1.9.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

dsfns-1.9-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file dsfns-1.9.tar.gz.

File metadata

  • Download URL: dsfns-1.9.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for dsfns-1.9.tar.gz
Algorithm Hash digest
SHA256 c0fe25661cd70f9cd9fbbe790979d09be9c2631bceb757f1b3fa9a3c48cbd2fb
MD5 f54311fa3a90058f69673dff6848d852
BLAKE2b-256 5825d6b2f1984bfc415af2c7f57e36d964dd854f76211ac4c349045dff81460d

See more details on using hashes here.

File details

Details for the file dsfns-1.9-py3-none-any.whl.

File metadata

  • Download URL: dsfns-1.9-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for dsfns-1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 19e26a8e97f8a380c79f130299ac38c7c18f84ae21475651b84dbfd462c5aae6
MD5 f8c5aa4d46806b3fd0855af1cb3ab387
BLAKE2b-256 c27c47addeab045e59eb1c34d937194daa25a47dc50e40dba7b8396a3b6e7e69

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