-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinternship_task_01.py
111 lines (88 loc) · 2.99 KB
/
internship_task_01.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# -*- coding: utf-8 -*-
"""Internship_task#01.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1RsJc0tSCn6XHxo7yL5INrls0jNTIG1rG
"""
#importing pandas library
import pandas as pd
#import matplotlib
import matplotlib.pyplot as plt
#importing seaborn library
import seaborn as sns
#loading data
student_performance=pd.read_csv('/content/Student_performance_data _.csv')
df=pd.DataFrame(student_performance)
# View first five rows of the dataset
student_performance.head()
student_performance.isnull().sum()
#Total Students
print(df['StudentID'].count())
#Total Extracurricular
Extracurricular_counts = df['Extracurricular'].value_counts()
print(Extracurricular_counts)
#Total Parental Support
ParentalSupport_counts = df['ParentalSupport'].value_counts()
print(ParentalSupport_counts)
#Gender
Gender_counts = df['Gender'].value_counts()
print(Gender_counts)
Gender_counts = df.groupby(['Gender', 'Gender']).size().unstack()
# Plotting
Gender_counts.plot(kind='bar', stacked=True,colormap='plasma',)
plt.ylabel('Count')
plt.xlabel('Gender')
plt.grid(True)
plt.title('Count of Gender')
plt.show()
count_students = df.groupby(['Age', 'Age']).size().unstack()
# Plotting
count_students.plot(kind='bar', stacked=True,colormap='plasma',)
plt.ylabel('Count')
plt.xlabel('Age')
plt.title('Count by Age')
plt.show()
# Plot Tutoring
Tutoring_counts = df['Tutoring'].value_counts()
plt.pie(Tutoring_counts, labels=Tutoring_counts.index, autopct='%1.1f%%',startangle=90)
plt.title('Distribution of Tutoring')
plt.axis('equal')
plt.show()
import seaborn as sns
import matplotlib.pyplot as plt
# Create a DataFrame to get counts of students with different GPA values for extracurricular participation
gpa_counts = df.groupby(['Extracurricular', 'Gender']).size().reset_index(name='Count')
# Bar plot for the counts
sns.barplot(data=gpa_counts, x='Extracurricular', y='Count', hue='Gender', palette='inferno')
plt.ylabel('Count')
plt.xlabel('Extracurricular Participation')
plt.title('Count of Students by Extracurricular Participation and Gender')
plt.grid(True)
plt.show()
# Plot Ethnicity & ParentalSupport
sns.countplot(data=df, x='Ethnicity',hue='ParentalSupport',palette='cividis')
plt.xlabel('Ethnicity')
plt.ylabel('ParentalSupport')
plt.grid(True)
plt.title('Ethnicity & ParentalSupport')
plt.show()
# Plot Sports
Sports_counts = df['Sports'].value_counts()
plt.pie(Sports_counts, labels=Sports_counts.index, autopct='%1.1f%%',startangle=90)
plt.title('Distribution of Sports')
plt.axis('equal')
plt.show()
# Plot ParentalSupport & ParentalEducation
sns.countplot(data=df, x='ParentalSupport',hue='ParentalEducation',palette='viridis')
plt.xlabel('ParentalSupport')
plt.ylabel('ParentalEducation')
plt.grid(True)
plt.title('ParentalSupport & ParentalEducation')
plt.show()
# Plot GradeClass & Tutoring
sns.countplot(data=df, x='GradeClass',hue='Tutoring',palette='viridis')
plt.xlabel('GradeClass')
plt.ylabel('Tutoring')
plt.grid(True)
plt.title('GradeClass & Tutoring')
plt.show()