In [1]:
from google.colab import files
uploaded = files.upload()
Upload widget is only available when the cell has been executed in the current browser session. Please rerun this cell to enable.
Saving school_totals_nv_2019.csv to school_totals_nv_2019 (2).csv
In [2]:
import sys
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
In [3]:
st = pd.read_csv('school_totals_nv_2019.csv')
In [4]:
st
Out[4]:
Local Education Agency Code Master District Code Master District Name School Code School Name Total
0 1 1 Churchill 1202 Northside Early ES 136
1 1 1 Churchill 1205 Best ES 517
2 1 1 Churchill 1206 Lahontan ES 482
3 1 1 Churchill 1207 Numa 507
4 1 1 Churchill 1301 Churchill Co 783
... ... ... ... ... ... ...
711 18 103 NV State HS III 103101 NSHS Sunrise 80
712 18 104 NV State HS II 104101 NSHS Meadowood 55
713 18 105 Signature Preparatory 105101 Signature Prep 548
714 19 84 University Schools 19406 Davidson Acad 178
715 20 79 Independence HS 79903 Independence HS 43

716 rows × 6 columns

In [5]:
st.shape
Out[5]:
(716, 6)
In [6]:
st.columns
Out[6]:
Index(['Local Education Agency Code', 'Master District Code',
       'Master District Name', 'School Code', 'School Name', 'Total'],
      dtype='object')
In [7]:
st.index
Out[7]:
RangeIndex(start=0, stop=716, step=1)
In [8]:
st_w_header = pd.read_csv('school_totals_nv_2019.csv', header=None)
In [9]:
st_w_header
Out[9]:
0 1 2 3 4 5
0 Local Education Agency Code Master District Code Master District Name School Code School Name Total
1 1 1 Churchill 01202 Northside Early ES 136
2 1 1 Churchill 01205 Best ES 517
3 1 1 Churchill 01206 Lahontan ES 482
4 1 1 Churchill 01207 Numa 507
... ... ... ... ... ... ...
712 18 103 NV State HS III 103101 NSHS Sunrise 80
713 18 104 NV State HS II 104101 NSHS Meadowood 55
714 18 105 Signature Preparatory 105101 Signature Prep 548
715 19 84 University Schools 19406 Davidson Acad 178
716 20 79 Independence HS 79903 Independence HS 43

717 rows × 6 columns

In [10]:
st.iloc[0]
Out[10]:
Local Education Agency Code                     1
Master District Code                            1
Master District Name                    Churchill
School Code                                  1202
School Name                    Northside Early ES
Total                                         136
Name: 0, dtype: object
In [11]:
st.iloc[1]
Out[11]:
Local Education Agency Code            1
Master District Code                   1
Master District Name           Churchill
School Code                         1205
School Name                      Best ES
Total                                517
Name: 1, dtype: object
In [12]:
st.iloc[-1]
Out[12]:
Local Education Agency Code                 20
Master District Code                        79
Master District Name           Independence HS
School Code                              79903
School Name                    Independence HS
Total                                       43
Name: 715, dtype: object
In [13]:
st.iloc[:,0]
Out[13]:
0       1
1       1
2       1
3       1
4       1
       ..
711    18
712    18
713    18
714    19
715    20
Name: Local Education Agency Code, Length: 716, dtype: int64
In [14]:
st.iloc[:,1]
Out[14]:
0        1
1        1
2        1
3        1
4        1
      ... 
711    103
712    104
713    105
714     84
715     79
Name: Master District Code, Length: 716, dtype: int64
In [15]:
st.iloc[0:, -1]
Out[15]:
0      136
1      517
2      482
3      507
4      783
      ... 
711     80
712     55
713    548
714    178
715     43
Name: Total, Length: 716, dtype: int64
In [16]:
st.iloc[0:5]
Out[16]:
Local Education Agency Code Master District Code Master District Name School Code School Name Total
0 1 1 Churchill 1202 Northside Early ES 136
1 1 1 Churchill 1205 Best ES 517
2 1 1 Churchill 1206 Lahontan ES 482
3 1 1 Churchill 1207 Numa 507
4 1 1 Churchill 1301 Churchill Co 783
In [17]:
st.iloc[:,0:2]
Out[17]:
Local Education Agency Code Master District Code
0 1 1
1 1 1
2 1 1
3 1 1
4 1 1
... ... ...
711 18 103
712 18 104
713 18 105
714 19 84
715 20 79

716 rows × 2 columns

In [18]:
st.iloc[0:5, 3:5]
Out[18]:
School Code School Name
0 1202 Northside Early ES
1 1205 Best ES
2 1206 Lahontan ES
3 1207 Numa
4 1301 Churchill Co
In [19]:
st.iloc[[0,1,2,3],[2,3,5]]
Out[19]:
Master District Name School Code Total
0 Churchill 1202 136
1 Churchill 1205 517
2 Churchill 1206 482
3 Churchill 1207 507
In [20]:
st_sorted = st.sort_values(by='Total',ascending=False)
In [21]:
st_sorted
Out[21]:
Local Education Agency Code Master District Code Master District Name School Code School Name Total
700 18 85 Nevada Connections Academy 85405 NV Connections ACAD 3468
345 2 2 Clark 2612 Coronado 3467
307 2 2 Clark 2403 Rancho 3308
349 2 2 Clark 2618 Arbor View 3298
305 2 2 Clark 2401 Clark 3250
... ... ... ... ... ... ...
501 12 12 Nye 12317 Duckwater MS 6
389 3 3 Douglas 3901 Douglas ALT ALT 6
447 8 8 Lander 8602 Austin School 6
372 2 2 Clark 2939 Juvenile Det ES 1
390 3 3 Douglas 3903 Douglas Adult 1

716 rows × 6 columns

In [22]:
st_top7=st_sorted.head(7)
In [23]:
st_top7
Out[23]:
Local Education Agency Code Master District Code Master District Name School Code School Name Total
700 18 85 Nevada Connections Academy 85405 NV Connections ACAD 3468
345 2 2 Clark 2612 Coronado 3467
307 2 2 Clark 2403 Rancho 3308
349 2 2 Clark 2618 Arbor View 3298
305 2 2 Clark 2401 Clark 3250
353 2 2 Clark 2623 Desert Oasis HS 3239
328 2 2 Clark 2427 Shadow Ridge HS 3232
In [24]:
st_top7['School Name']
Out[24]:
700    NV Connections ACAD
345               Coronado
307                 Rancho
349             Arbor View
305                  Clark
353        Desert Oasis HS
328        Shadow Ridge HS
Name: School Name, dtype: object
In [25]:
st_top7['School Name'].values
Out[25]:
array(['NV Connections ACAD', 'Coronado', 'Rancho', 'Arbor View', 'Clark',
       'Desert Oasis HS', 'Shadow Ridge HS'], dtype=object)
In [26]:
import seaborn as sns
sns.set()
plt.figure(figsize=(10,6))
plt.bar(x=st_top7['School Name'], height=st_top7['Total'], color='rgbymcw')
plt.xticks(rotation=45)
plt.title('The Top Seven Highest Enrollment Schools in Nevada in 2019')
/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:4: MatplotlibDeprecationWarning: Using a string of single character colors as a color sequence is deprecated. Use an explicit list instead.
  after removing the cwd from sys.path.
Out[26]:
Text(0.5, 1.0, 'The Top Seven Highest Enrollment Schools in Nevada in 2019')
In [27]:
st.columns
Out[27]:
Index(['Local Education Agency Code', 'Master District Code',
       'Master District Name', 'School Code', 'School Name', 'Total'],
      dtype='object')
In [28]:
st['Total'].sum()
Out[28]:
500860
In [29]:
st.loc[0]
Out[29]:
Local Education Agency Code                     1
Master District Code                            1
Master District Name                    Churchill
School Code                                  1202
School Name                    Northside Early ES
Total                                         136
Name: 0, dtype: object
In [30]:
st.loc[1]
Out[30]:
Local Education Agency Code            1
Master District Code                   1
Master District Name           Churchill
School Code                         1205
School Name                      Best ES
Total                                517
Name: 1, dtype: object
In [31]:
st.loc[1, 'Total']
Out[31]:
517
In [32]:
st.loc[st.Total>3000]
Out[32]:
Local Education Agency Code Master District Code Master District Name School Code School Name Total
305 2 2 Clark 2401 Clark 3250
307 2 2 Clark 2403 Rancho 3308
318 2 2 Clark 2416 Green Valley 3074
326 2 2 Clark 2425 Palo Verde HS 3182
328 2 2 Clark 2427 Shadow Ridge HS 3232
329 2 2 Clark 2428 Liberty 3039
343 2 2 Clark 2609 Desert Pines 3077
345 2 2 Clark 2612 Coronado 3467
349 2 2 Clark 2618 Arbor View 3298
353 2 2 Clark 2623 Desert Oasis HS 3239
700 18 85 Nevada Connections Academy 85405 NV Connections ACAD 3468
In [33]:
clark = st.loc[st['Master District Name']=='Clark']
In [34]:
clark
Out[34]:
Local Education Agency Code Master District Code Master District Name School Code School Name Total
7 2 2 Clark 2061 Abston ES 781
8 2 2 Clark 2062 Jenkins ES 600
9 2 2 Clark 2064 Ellis 653
10 2 2 Clark 2065 Ortwein 751
11 2 2 Clark 2066 Barber 712
... ... ... ... ... ... ...
371 2 2 Clark 2935 Variety School ES 27
372 2 2 Clark 2939 Juvenile Det ES 1
373 2 2 Clark 2941 Adult Ed 2929
374 2 2 Clark 2955 Desert Rose ALT 289
375 2 2 Clark 2957 Mission HS 113

369 rows × 6 columns

In [35]:
clark_sorted = clark.sort_values(['Total'], ascending=False)
In [36]:
clark_sorted
Out[36]:
Local Education Agency Code Master District Code Master District Name School Code School Name Total
345 2 2 Clark 2612 Coronado 3467
307 2 2 Clark 2403 Rancho 3308
349 2 2 Clark 2618 Arbor View 3298
305 2 2 Clark 2401 Clark 3250
353 2 2 Clark 2623 Desert Oasis HS 3239
... ... ... ... ... ... ...
48 2 2 Clark 2104 Reid ES 26
20 2 2 Clark 2075 Northwest CTA ES 17
367 2 2 Clark 2927 Desert Willow 14
47 2 2 Clark 2103 Lundy 14
372 2 2 Clark 2939 Juvenile Det ES 1

369 rows × 6 columns

In [37]:
clark['Total'].sum()
Out[37]:
331921
In [38]:
clark_top7 = clark_sorted.head(7)
In [39]:
clark_top7
Out[39]:
Local Education Agency Code Master District Code Master District Name School Code School Name Total
345 2 2 Clark 2612 Coronado 3467
307 2 2 Clark 2403 Rancho 3308
349 2 2 Clark 2618 Arbor View 3298
305 2 2 Clark 2401 Clark 3250
353 2 2 Clark 2623 Desert Oasis HS 3239
328 2 2 Clark 2427 Shadow Ridge HS 3232
326 2 2 Clark 2425 Palo Verde HS 3182
In [40]:
import seaborn as sns
sns.set()
plt.figure(figsize=(10,6))
plt.bar(x=clark_top7['School Name'], height=clark_top7['Total'], color='rgbymcw')
plt.xticks(rotation=45)
plt.title('The Top Seven Highest Enrollment Schools in Clark County in 2019')
/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:4: MatplotlibDeprecationWarning: Using a string of single character colors as a color sequence is deprecated. Use an explicit list instead.
  after removing the cwd from sys.path.
Out[40]:
Text(0.5, 1.0, 'The Top Seven Highest Enrollment Schools in Clark County in 2019')
In [41]:
order = [1,2,3,4,5,6,7]
clark_top7_df = pd.DataFrame(clark_top7, columns=['School Name','Total'])
clark_top7_df['order']=order
clark_top7_insert =pd.DataFrame(clark_top7_df, columns=['order','School Name','Total'])
clark_top7_insert 
Out[41]:
order School Name Total
345 1 Coronado 3467
307 2 Rancho 3308
349 3 Arbor View 3298
305 4 Clark 3250
353 5 Desert Oasis HS 3239
328 6 Shadow Ridge HS 3232
326 7 Palo Verde HS 3182
In [42]:
clark_top7_insert.rename(columns={'School Name':'school_name', 'Total':'total'})
Out[42]:
order school_name total
345 1 Coronado 3467
307 2 Rancho 3308
349 3 Arbor View 3298
305 4 Clark 3250
353 5 Desert Oasis HS 3239
328 6 Shadow Ridge HS 3232
326 7 Palo Verde HS 3182
In [43]:
clark_top7_new = clark_top7_insert.set_index('order')
clark_top7_new
Out[43]:
School Name Total
order
1 Coronado 3467
2 Rancho 3308
3 Arbor View 3298
4 Clark 3250
5 Desert Oasis HS 3239
6 Shadow Ridge HS 3232
7 Palo Verde HS 3182
In [44]:
clark_top7
Out[44]:
Local Education Agency Code Master District Code Master District Name School Code School Name Total
345 2 2 Clark 2612 Coronado 3467
307 2 2 Clark 2403 Rancho 3308
349 2 2 Clark 2618 Arbor View 3298
305 2 2 Clark 2401 Clark 3250
353 2 2 Clark 2623 Desert Oasis HS 3239
328 2 2 Clark 2427 Shadow Ridge HS 3232
326 2 2 Clark 2425 Palo Verde HS 3182
In [45]:
clark_1 = clark_top7.loc[[345, 305, 326], ['School Name','Total']]
clark_1
Out[45]:
School Name Total
345 Coronado 3467
305 Clark 3250
326 Palo Verde HS 3182
In [48]:
clark2 = clark_top7.loc[345]
clark2
Out[48]:
Local Education Agency Code           2
Master District Code                  2
Master District Name              Clark
School Code                        2612
School Name                    Coronado
Total                              3467
Name: 345, dtype: object
In [49]:
clark3 = clark_top7.loc[345:328]
clark3
Out[49]:
Local Education Agency Code Master District Code Master District Name School Code School Name Total
345 2 2 Clark 2612 Coronado 3467
307 2 2 Clark 2403 Rancho 3308
349 2 2 Clark 2618 Arbor View 3298
305 2 2 Clark 2401 Clark 3250
353 2 2 Clark 2623 Desert Oasis HS 3239
328 2 2 Clark 2427 Shadow Ridge HS 3232
In [51]:
clark4 = clark_top7.loc[345:328, ['School Name']]
clark4
Out[51]:
School Name
345 Coronado
307 Rancho
349 Arbor View
305 Clark
353 Desert Oasis HS
328 Shadow Ridge HS
In [52]:
clark5 = clark_top7.loc[:, ['School Name','Total']]
clark5
Out[52]:
School Name Total
345 Coronado 3467
307 Rancho 3308
349 Arbor View 3298
305 Clark 3250
353 Desert Oasis HS 3239
328 Shadow Ridge HS 3232
326 Palo Verde HS 3182
In [54]:
clark6 = clark_top7.loc[clark_top7['School Name']=='Coronado']
clark6
Out[54]:
Local Education Agency Code Master District Code Master District Name School Code School Name Total
345 2 2 Clark 2612 Coronado 3467
In [58]:
clark7 = st.loc[st['School Name']=='Clark', ['School Name','Total']]
clark7
Out[58]:
School Name Total
305 Clark 3250