# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/Tutorials/05_missingness.ipynb.

# %% auto 0
__all__ = ['empty_columns', 'empty_rows', 'empty_columns_with_threshold', 'remove_empty_columns']

# %% ../nbs/Tutorials/05_missingness.ipynb 2
import pandas as pd

def empty_columns(df:pd.DataFrame=None):
    """
    Returns a list of column names that have all NaN values.

    Args:
        df (pandas.DataFrame): The input DataFrame.

    Returns:
        list: A list of column names that have all NaN values.
    """
    # Get the column names where all values are NaN
    empty_cols = df.columns[df.isna().all()].tolist()
    return empty_cols

# %% ../nbs/Tutorials/05_missingness.ipynb 3
import pandas as pd
# return all empty rows
def empty_rows(df:pd.DataFrame=None):
    """
    Returns a list of row indices that have all NaN values.

    Args:
        df (pandas.DataFrame): The input DataFrame.

    Returns:
        list: A list of row indices that have all NaN values.
    """
    # Get the row indices where all values are NaN
    empty_rows = df.index[df.isna().all(axis=1)].tolist()
    return empty_rows


# %% ../nbs/Tutorials/05_missingness.ipynb 4
import pandas as pd
def empty_columns_with_threshold(df, threshold):
    """
    Returns a list of column names that have a percentage of NaN values greater than or equal to the specified threshold.

    Args:
        df (pandas.DataFrame): The input DataFrame.
        threshold (float): The minimum percentage of NaN values required (between 0 and 1).

    Returns:
        list: A list of column names that have a percentage of NaN values greater than or equal to the threshold.
    """
    # Calculate the percentage of NaN values for each column
    nan_percentages = (df.isna().sum() / len(df)) * 100
    # Get the column names where the percentage of NaN values is greater than or equal to the threshold
    columns_to_drop = nan_percentages[nan_percentages >= threshold].index.tolist()
    return columns_to_drop

# %% ../nbs/Tutorials/05_missingness.ipynb 5
import pandas as pd
from .handle_missingness import empty_columns

def remove_empty_columns(df):

    """
    Removes columns that have all NaN values from the input DataFrame.

    Args:
        df (pandas.DataFrame): The input DataFrame.

    Returns:
        pandas.DataFrame: The DataFrame with empty columns removed.
    """
    # Get the column names that have all NaN values
    empty_cols = empty_columns(df)
    # Drop the columns with all NaN values
    df = df.drop(empty_cols, axis=1)
    return df
