Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

COMPUTATIONAL DATA ANALYTICS - 102150401

PRACTICAL 1

Perform descriptive analytics of the given data. The cumulative grade point average (CGPA) of students are given in the dataset.

(A) Calculate the mean, median and mode and the standard deviation

import pandas as pd
import numpy as np
import scipy as sc
import matplotlib.pyplot as plt
import seaborn as sea
import statistics as st
import sklearn

df = pd.read_csv('/content/data (1).csv')

df.head(10)

1st 2nd 3rd 4th 5th College Code Gender Roll Roll no. Subject Code

0 8.11 7.68 7.11 7.43 8.18 115 Female NaN 17020.0 16

1 6.48 5.90 4.15 4.29 4.96 115 Male NaN 17021.0 16

2 8.41 8.24 7.52 8.25 7.75 115 Female NaN 17022.0 16

3 7.33 6.83 6.33 6.79 6.89 115 Male NaN 17023.0 16

4 7.89 7.34 7.22 7.32 7.46 115 Male NaN 17024.0 16

5 7.33 6.72 6.48 6.50 7.39 115 Male NaN 17025.0 16

6 7.15 6.72 6.89 6.86 7.64 115 Male NaN 17026.0 16

7 6.74 6.38 4.93 5.64 6.75 115 Male NaN 17027.0 16

8 7.89 7.45 6.96 7.71 8.00 115 Female NaN 17028.0 16

9 7.30 6.34 6.30 6.61 6.18 115 Male NaN 17029.0 16

# Calculate the mean


aa=df['1st']
mean = np.mean(aa)
print("Mean:", mean)

Mean: 7.038863636363637

# Calculate the median


median = np.nanmedian(aa)
print("Median:", median)

Median: 7.07

# Calculate the mode


mode = st.mode(aa)
print("Mode:", mode)

Mode: 7.33

# Calculate the standard deviation


stdev = np.nanstd(aa)
print("Standard Deviation:", stdev)

Standard Deviation: 0.8570754074947148

(B) Calculate the 90th and 95th percentile of CGPA.

# Calculate the 90th percentile


percentile_90 = np.nanpercentile(aa, 90)
print("90th percentile of CGPA:", percentile_90)

90th percentile of CGPA: 8.11

(C)) Calculate the inter quartile range (IQR)

Vatsal Kardani 12202020503022


COMPUTATIONAL DATA ANALYTICS - 102150401

# Calculate the IQR


q1 = np.nanpercentile(aa, 25)
q3 = np.nanpercentile(aa, 75)
iqr = q3 - q1

print("Q1:", q1)
print("Q3:", q3)
print("IQR:", iqr)

Q1: 6.44
Q3: 7.59
IQR: 1.1499999999999995

(D)The Dean of the school believes that the CGPA is a right tailed distribution. Is there an evidence to supportdean‘s belief?

mm=sea.distplot(aa)
print('Data is left skewed')

<ipython-input-37-af1a1c56c674>:1: UserWarning:

`distplot` is a deprecated function and will be removed in seaborn v0.14.0.

Please adapt your code to use either `displot` (a figure-level function with
similar flexibility) or `histplot` (an axes-level function for histograms).

For a guide to updating your code to use the new functions, please see
https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751

mm=sea.distplot(aa)
Data is left skewed

(E) Create a histogram for the data, what should be the ideal number of bins in the histogram.

plt.hist(aa)
plt.show()

Vatsal Kardani 12202020503022


COMPUTATIONAL DATA ANALYTICS - 102150401

Colab paid products - Cancel contracts here

Vatsal Kardani 12202020503022

You might also like