Package: dstrial
dstrial Module DocumentationOverviewThis documentation explains the functions available in theDatacleaningmodule, which is designed to assist in data cleaning and analytics tasksCreating the an instanceThrough this process, we are calling our class which will help us access the various functions to be used.fromdstrialimportDatacleaningdata_cleaner=Datacleaning()So for all the remaining part of our code, we shall be using the data_cleaner.Table of Contentscolumnssummaryread_dataheadmissing_valuescol_missing_valueremove_empty_columnsdata_typescat_colscont_colsdistributionsdata_typescol_distcat_distcol_cat_distremove_missingvaluesdropoutliersoutliers_singleremove_outlierscorr_matrixcont_corrcont_to_contcat_to_catcountplotcontingency_tableChi_squarecombined_boplotsingleAnovacont_to_catgetdatadata_cleaningcolumnsFunction Name: columnsThis function returns the columns of the loaded dataset.ParametersNoneReturn ValueReturns a list of column names in the dataset.summaryFunction Name: summaryThis function is used to generate summary statistics of the data. It provides valuable information about the distribution, central tendency, and spread of the data. It calculates statistics for each numeric column in the data.The statistics provided by the summary function include:Count: The number of non-null values in the column.Mean: The arithmetic mean (average) of the values.Standard Deviation: A measure of the spread or dispersion of the values.Minimum: The minimum value in the column.25th Percentile (Q1): The value below which 25% of the data falls.50th Percentile (Median or Q2): The middle value of the data.75th Percentile (Q3): The value below which 75% of the data falls.Maximum: The maximum value in the column.Then to acategorical column, The summary function generates statistics such as:Count: The number of non-null values in the column.Unique: The number of unique categories or levels in the column.Top: The most frequent category in the column.Freq: The frequency of the top category.ParametersNoneReturn ValueReturns a dataframe containing the summary statistics of the data.read_dataFunction Name: read_dataThis function is used to read data from a file. It supports reading data from a CSV file, Excel file, and a JSON file. The function automatically detects the file type and reads the data accordingly.Parametersfile_path: The path to the file to be read.Return ValueReturns a dataframe containing the data from the file.headFunction Name: headThis function is used to display the first few rows of the data. It is useful to get a quick overview of the data.Parametersnumber: The number of rows to display.Return ValueReturns a dataframe containing the first few rows of the data.missing_valuesFunction Name: missing_valuesThis function is used to check for missing values in the data.ParametersNoneReturn ValueReturns a dataframe containing the number of missing values in each column.col_missing_valueFunction Name: col_missing_valueThis function is used to check for missing values in a specific column.Parameterscol_name: The name of the column to check for missing values.Return ValueReturns the number of missing values in the specified column.remove_empty_columnsFunction Name: remove_empty_columnsThis function is used to remove columns that have no values. It is useful to remove columns that have no values as they do not provide any useful information.ParametersNoneReturn ValueReturns a dataframe with the empty columns removed.data_typesFunction Name: data_typesThis function is used to check the data types of the columns and the creates subsets of the data based on the data types. It creates a subset of the data containing only the categorical columns and another subset containing only the numeric columns.ParametersNoneReturn ValueNonecat_colsFunction Name: cat_colsThis function is used to get the categorical columns in the data.ParametersNoneReturn ValueReturns a dataframe of the categorical columns in the data.cont_colsFunction Name: cont_colsThis function is used to get the numeric columns in the data.ParametersNoneReturn ValueReturns a dataframe of the numeric columns in the data.distributionsFunction Name: distributionsThis function is used to plot the distribution of the numeric columns in the data. It plots a histogram for each numeric column in the data.It is useful to get an idea of the distribution of the data. It can be used to identify outliers and skewness in the data.ParametersNoneReturn ValueNonecol_distFunction Name: col_distThis function is used to plot the distribution of a specific numeric column in the data.Parameterscol: The name of the column to plot the distribution for.Return ValueNonecat_distFunction Name: cat_distThis function is used to plot the distribution of a all categorical columns in the data.ParametersNoneReturn ValueNonecol_cat_distFunction Name: col_cat_distThis function is used to plot the distribution of a specific categorical column in the data.Parameterscol: The name of the column to plot the distribution for.Return ValueNoneremove_missingvaluesFunction Name: remove_missingvaluesThis function is used to remove deal with rows that have  missing values (NA).
The funcion first removes all the duplicates that are within the data and also automatically removes all the empty columns.The missing values are then replaced with the mode of the column (the most occuring value) for categorical columns.For numeric columns, the missing values are replaced with either the mean or median of the column depending on the skewness of the data.ParametersNoneReturn ValueNonedropFunction Name: dropThis function is used to drop columns from the data.Parameterscolumn: This is a two way parameter. It can either be a string or a list of strings. If it is a string, it is the name of the column to drop. If it is a list of strings, it is a list of columns to drop.Return ValueNoneoutliersFunction Name: outliersThis function is used to plot the outliers in the data. It plots a boxplot for each numeric column in the data.It is useful to get an idea of the outliers in the data. It can be used to identify outliers in the data.ParametersNoneReturn ValueNoneoutliers_singleFunction Name: outliers_singleThis function is used to plot the outliers in a specific numeric column in the data.Parameterscolumn: The name of the numeric column to plot the outliers for.Return ValueNoneremove_outliersFunction Name: remove_outliersThis function is used to remove outliers from the data. It removes outliers from all the numeric columns in the data.The concept of outliers is based on the interquartile range (IQR). The IQR is the difference between the 75th percentile (Q3) and the 25th percentile (Q1). The IQR is used to identify outliers by defining limits on the sample values that are a factor k of the IQR below the 25th percentile or above the 75th percentile. The common value for the factor k is the value 1.5. This is the default value used by the function.ParametersNoneReturn ValueNonecorr_matrixFunction Name: corr_matrixThis function is used to plot the correlation matrix of the data. It plots a heatmap of the correlation matrix of the data.It is useful to get an idea of the correlation between the numeric columns in the data. It can be used to identify highly correlated columns in the data.ParametersNoneReturn Valuecont_corrFunction Name: cont_corrThis function is used to plot a pairplot of the numeric columns in the data.ParametersNoneReturn ValueNonecont_to_contFunction Name: cont_to_contThe function is used to show significant relationship or difference between two numeric columns in the data.
This is achieved through plotting a scatter plot of two numeric columns in the data.
The function also goes on to indicate the correlation value between the two columns.Parameterscol1: This is a two way parameter. It can either be a string or a list of strings. If it is a string, it is the name of the first column to plot. If it is a list of strings, it is a list of columns to plot.col2: This is a two way parameter. It can either be a string or a list of strings. If it is a string, it is the name of the second column to plot. If it is a list of strings, it is a list of columns to plot.Return ValueNonecat_to_catFunction Name: cat_to_catThe function is used to show significant relationship or difference between two categorical columns in the data.
The function hence displays a contingency table of the two categorical columns in the data. and also plots a comparative bar graph of the two columns.Parameterscol1: This is a two way parameter. It can either be a string or a list of strings. If it is a string, it is the name of the first column to plot. If it is a list of strings, it is a list of columns to plot.col2: This is a two way parameter. It can either be a string or a list of strings. If it is a string, it is the name of the second column to plot. If it is a list of strings, it is a list of columns to plot.Return ValueNonecountplotFunction Name: countplotThe function is used to plot a countplot of a two categorical columns in the data.
This is a way of showing the distribution of the two categorical columns in the data.Parameterscol1: This is a string. It is the name of the first column to plot.col2: This is a string. It is the name of the second column to plot.Return ValueNonecontingency_tableFunction Name: contingency_tableThe function is used to show significant relationship or difference between two categorical columns in the data.
The function hence displays a contingency table of the two categorical columns in the data.Parameterscol1: This is a string. It is the name of the first column to plot.col2: This is a string. It is the name of the second column to plot.Return ValueNoneChi_squareFunction Name: Chi_squareThe function tests for a statistically significant relationship between nominal and ordinal variables. In other words, it tells us whether two variables are independent of one another.Parameterscol1: This is a string. It is the name of the first column categorical column.col2: This is a string. It is the name of the second column categorical column.Return ValueA string indicating whether the two columns are independent or not.combined_boplotFunction Name: combined_boplotThe function is used to plot a set of side by side box plots, one for each of the categories.Parameterscol1: This is a string. It is the name of the first column continuous column.col2: This is a string. It is the name of the second column categorical column.Return ValueNonesingleAnovaFunction Name: singleAnovaThe function is used to test for a statistically significant difference between the means of two or more groups.Parameterscol1: This is a string. It is the name of the first column continuous column.col2: This is a string. It is the name of the second column categorical column.Return ValueA string indicating whether the two columns are independent or not.cont_to_catFunction Name: cont_to_catThe function is used to show significant relationship or difference between a continuous and a categorical column in the data.The function hence displays a side by side boxplot of the continuous column and a categorical column in the data.Parameterscol1: This is two way parameter. It can either be a string or a list of strings. If it is a string, it is the name of the first column continuous column. If it is a list of strings, it is a list of columns to plot.On the other hand, it can be a a string or a list of strings of categorical columns.col2: This is two way parameter. It can either be a string or a list of strings. If it is a string, it is the name of the second column categorical column. If it is a list of strings, it is a list of columns to plot.On the other hand, it can be a a string or a list of strings of continuous columns.Return ValueA string indicating whether the two columns are independent or not.getdataFunction Name: getdataThe function returns the data that has been cleaned and preprocessed.ParametersNoneReturn ValueReturns a dataframe containing the cleaned data.data_cleaningFunction Name: data_cleaningThe function is used to clean the data. It performs the following operations:Removes empty columns.Removes duplicate rows.Deals with missing values appropriately.Removes outliers.ParametersNoneReturn ValueA dataframe containing the cleaned data.FUNCTIONSUsage Examplefromdstrial1importDatacleaningdata_cleaner=Datacleaning()columns_list=data_cleaner.columns()