distribution analysis pandas code example

Example 1: distribution analysis pandas

data.loc[(data["Gender"]=="Female") & (data["Education"]=="Not Graduate") & (data["Loan_Status"]=="Y"), ["Gender","Education","Loan_Status"]]

Example 2: distribution analysis pandas

#Create a new function:
def num_missing(x):
  return sum(x.isnull())

#Applying per column:
print "Missing values per column:"
print data.apply(num_missing, axis=0) #axis=0 defines that function is to be applied on each column

#Applying per row:
print "\nMissing values per row:"
print data.apply(num_missing, axis=1).head() #axis=1 defines that function is to be applied on each row

Example 3: distribution analysis pandas

import pandas as pd
import numpy as np
data = pd.read_csv("train.csv", index_col="Loan_ID")

Example 4: distribution analysis pandas

#First we import scipy function to determine the mode
from scipy.stats import mode
mode(data['Gender'])