wrangle_in_py.column_drop_threshold =================================== .. py:module:: wrangle_in_py.column_drop_threshold Functions --------- .. autoapisummary:: wrangle_in_py.column_drop_threshold.column_drop_threshold Module Contents --------------- .. py:function:: column_drop_threshold(df, threshold, variance=None) Returns a copy of the dataframe inputted with columns removed if they did not meet the threshold specified, and with columns removed if they had a coefficient of variance lower than specified. :param df: The input pandas dataframe whose missingness threshold and coefficient of variance needs to be checked :type df: pd.DataFrame :param threshold: Must be 0 <= threshold <= 1 The threshold for the proportion of missing values to allow in each column of the dataframe, Columns with a larger proportion of missing observations than the threshold will be removed from the dataframe :type threshold: float :param variance: Default is None The lowest coefficient of variance to allow in any one column of the dataframe Columns with a lower variance than specified will be removed from the dataframe A column must have at least 2 numbers for coefficient of variance to be calculated because the coefficient of variance cannot be calculated with 1 or 0 numbers. :type variance: float :raises TypeError :: If the input for df is not a pandas DataFrame. :raises ValueError :: If the input for threshold is not a float and in the inclusive range 0 and 1. Or if the input for variance is not a float >=0. :returns: A new dataframe where each column meets or exceeds the specified allowable missingness threshold, and the variance threshold. Any columns previously not meeting the thresholds have been removed. :rtype: pd.DataFrame .. rubric:: Examples >>> data = {'apple': [1, 2, NaN], 'banana': [3, 4, 5], 'kiwi': [NaN, 30, NaN], 'peach': [2, 2, 2]} >>> df = pd.DataFrame(data) >>> column_drop_threshold(df, 0.35, 0.1) apple banana 0 1 3 1 2 4 2 NaN 5