Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

function for getting the basic statistic of our Dataframe in one go

#Creating a function that does all of the above tasks in one go:

def get_basic_stats(dfname):
    print("Shape of dataframe is " + str(dfname.shape))
    print("Below are datatypes of columns in DF")
    print(dfname.dtypes.sort_values())
    print("Below are missing values in each column")
    print(dfname.isna().sum().sort_values())
    print("Below are percentage of the missing values in each column")
    print(dfname.isna().sum().sort_values(ascending=False) / len(dfname))
    print("Below are the number of unique values taken by a column")
    print(dfname.nunique().sort_values())
    print("Below are some records in DF")
    print("Below is distribution of numeric variables")
    print(dfname.describe())
    print(dfname.head())
    
    
get_basic_stats(df) #df here is the dataframe we wants to get it's statistic
 
PREVIOUS NEXT
Tagged: #function #basic #statistic #Dataframe
ADD COMMENT
Topic
Name
9+4 =