The dataset is about consists of Placement data of MBA students of a B-school. It includes the following features:
You can download the dataset from kaggle https://www.kaggle.com/benroshan/factors-affecting-campus-placement?select=Placement_Data_Full_Class.csv
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv('Placement.csv')
df.head()
fig, axes = plt.subplots(nrows = 1, ncols = 2,figsize =(10,5))
'''1. Creating the histogram for hsc_p with 10 bins'''
axes[0].set_title('hsc histogram')
axes[0].hist(df['hsc_p'],bins=10)
axes[0].set_xlabel('hsc_percentage')
axes[0].set_ylabel('frequency')
'''2. Creating the histogram for ssc_p with 10 bins'''
axes[1].set_title('ssc histogram')
axes[1].hist(df['ssc_p'],bins=10)
axes[1].set_xlabel('ssc_percentage')
axes[1].set_ylabel('frequency')
plt.tight_layout()
plt.show()
'''1.Showing the CDF and PDF using 'hsc_p' column'''
fig, axes = plt.subplots(nrows = 1, ncols = 2,figsize =(10,5))
count_hsc, bin_edges_hsc = np.histogram(df['hsc_p'],bins = 10, density = True)
print("counts_hsc: ",count_hsc)
pdf_hsc = (count_hsc/(sum(count_hsc)))
print("pdf_hsc:",pdf_hsc)
print("bin_edges_hsc: ",bin_edges_hsc)
axes[0].set_title('CDF and PDF -- HSC_P')
axes[0].plot(bin_edges_hsc[1:],pdf_hsc)
axes[0].set_xlabel("Hsc Percentage")
axes[0].set_ylabel("% of distribution")
cdf_hsc = np.cumsum(pdf_hsc)
axes[0].plot(bin_edges_hsc[1:],cdf_hsc)
'''2. Showing the CDF and PDF using the ssc_p column'''
count_ssc, bin_edges_ssc = np.histogram(df['ssc_p'],bins = 10, density = True)
print("counts_ssc: ",count_ssc)
pdf_ssc = (count_ssc/(sum(count_ssc)))
print("pdf_ssc:",pdf_ssc)
print("bin_edges_ssc: ",bin_edges_ssc)
axes[1].set_title('CDF and PDF -- SSC_P')
axes[1].plot(bin_edges_ssc[1:],pdf_ssc)
axes[1].set_xlabel("SSC Percentage")
axes[1].set_ylabel("% of distribution")
cdf_ssc = np.cumsum(pdf_ssc)
axes[1].plot(bin_edges_ssc[1:],cdf_ssc)
plt.tight_layout()
plt.show()