In [2]:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import seaborn as sns
%matplotlib inline

In [3]:
#df = pd.read_csv('/home/tribilium/Downloads/grades.csv', header=None, names=['grades'])
df = pd.read_csv('grades.csv', header=None, names=['grades'])

In [5]:
df.head()


Out[5]:
grades
0 81
1 71
2 67
3 54
4 90

In [6]:
df.describe()


Out[6]:
grades
count 32.000000
mean 83.500000
std 9.638632
min 54.000000
25% 81.000000
50% 86.000000
75% 90.000000
max 97.000000

In [7]:
df.columns[0]
grade_mat = df.as_matrix()

In [9]:
grade_mat


Out[9]:
array([[81],
       [71],
       [67],
       [54],
       [90],
       [93],
       [90],
       [91],
       [97],
       [94],
       [83],
       [91],
       [90],
       [84],
       [84],
       [83],
       [87],
       [87],
       [88],
       [95],
       [86],
       [92],
       [66],
       [87],
       [77],
       [84],
       [86],
       [82],
       [88],
       [81],
       [69],
       [74]], dtype=int64)

In [10]:
grade_mat.shape


Out[10]:
(32, 1)

In [14]:
plt.style.use('fivethirtyeight')
fig, ax = plt.subplots()
plt.hist(grade_mat, bins=[50, 60, 70, 80, 90, 100])
ax.set_xlim([50, 100])
ax.set_xlabel('Grade Range')
ax.set_ylabel('Number of Students')
ax.set_title('Histogram of Exam 1 Grades - ENGR262 Winter 2018')


Out[14]:
Text(0.5,1,'Histogram of Exam 1 Grades - ENGR262 Winter 2018')

In [15]:
plt.style.use('fivethirtyeight')
fig, ax = plt.subplots()
plt.hist(df['grades'], bins=[50, 60, 70, 80, 90, 100])
ax.set_xlim([50, 100])
ax.set_xlabel('Grade Range')
ax.set_ylabel('Number of Students')
ax.set_title('Histogram of Exam 1 Grades - ENGR262 Winter 2018')


Out[15]:
Text(0.5,1,'Histogram of Exam 1 Grades - ENGR262 Winter 2018')

In [16]:
min_grade = min(df['grades'])

In [17]:
min_grade


Out[17]:
54

In [18]:
min_grade=min_grade*.1

In [19]:
min_grade


Out[19]:
5.4000000000000004

In [23]:
min_grade_floor = np.floor(min_grade)

In [25]:
min_grade = min_grade_floor*10
min_grade = int(min_grade)

In [26]:
bin_array = np.arange(min_grade,110,10)
bin_array


Out[26]:
array([ 50,  60,  70,  80,  90, 100])

In [29]:
bin_array.tolist()


Out[29]:
[50, 60, 70, 80, 90, 100]

In [30]:
plt.style.use('fivethirtyeight')
fig, ax = plt.subplots()
plt.hist(df['grades'], bins=bin_array)
ax.set_xlim([min_grade, 100])
ax.set_xlabel('Grade Range')
ax.set_ylabel('Number of Students')
ax.set_title('Histogram of Exam 1 Grades - ENGR262 Winter 2018')


Out[30]:
Text(0.5,1,'Histogram of Exam 1 Grades - ENGR262 Winter 2018')

In [ ]: