The National Alliance of Concurrent Enrollment Partnerships

2015-16 Civil Rights Data Collection (CRDC)

Advanced Placement (AP) v. Dual Enrollment (DE)

Responses to the question: "Does the School Offer AP/DE?"

Alijah O'Connor - 2018



Exactly how prevalent are dual enrollment and advanced placement programs across the country? In the 2015-2016 CRDC survey, schools were asked to report whether or not they offered either of these programs, respectively. Looking at the 18,667 high schools from the filtered CRDC dataset (for more details, see the intital filtration methodology), the results are reported below in the follow ways:

- Nationally
- By School 9-12th Grade Enrollment
- By School Locale
- By School Non-White Student Percentage
- By School Vocational Status
- By State
- By Region (Accreditation)
- By Region (Census)
- By Region (NACEP)


In [1]:
from IPython.display import HTML

HTML('''<script>
code_show=true; 
function code_toggle() {
 if (code_show){
 $('div.input').hide();
 } else {
 $('div.input').show();
 }
 code_show = !code_show
} 
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()"><input type="submit" value="Click here to toggle on/off the raw code."></form>''')
Out[1]:
In [2]:
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

import plotly.plotly as py
import plotly.graph_objs as go
from plotly.offline import init_notebook_mode,iplot
init_notebook_mode(connected = True)

from my_functions.extra_functions import flag_grouper

%matplotlib inline
sns.set_style('whitegrid')
plt.rc('axes', titlesize = 14, titleweight = 'bold', labelweight = 'bold')
In [3]:
hs = pd.read_csv('../filtered_data/04_filter_final.csv', dtype = {'LEAID':np.object})

National

In [4]:
hs_total = len(hs)
de_total = len(hs[hs['SCH_DUAL_IND'] == 'Yes'])
de_offering_rate = round(de_total / hs_total * 100, 1) 
ap_total = len(hs[hs['SCH_APENR_IND'] == 'Yes'])
ap_offering_rate = round(ap_total / hs_total * 100, 1)

order = ['# HS Schools', '# Schools Offering DE', 'DE Offering Rate', 
         '# Schools Offering AP', 'AP Offering Rate']

pd.DataFrame({'# HS Schools': hs_total,
              '# Schools Offering DE': de_total,
              'DE Offering Rate': de_offering_rate,
              '# Schools Offering AP': ap_total,
              'AP Offering Rate': ap_offering_rate},
            index = ['National'])[order]
Out[4]:
# HS Schools # Schools Offering DE DE Offering Rate # Schools Offering AP AP Offering Rate
National 18684 13338 71.4 12764 68.3

By School 9-12th Grade Enrollment

- Schools were grouped into four categories based on how many students were enrolled in grades 9-12 in each one:
    - <100
    - 100 - 499
    - 500 - 1199
    - 1200+
In [5]:
"""Create a Size-of-School Classifier"""
hs['total_enrollment'] = hs['TOT_ENR_M'] + hs['TOT_ENR_F']
from my_functions.extra_functions import hs_enrollment_averager
hs['hs_total_enrollment'] = hs_enrollment_averager(hs) # Calculating HS Students from the Total_Enrollments in Schools
In [6]:
"""Assigning Size Groups based on HS Enrollments"""
from my_functions.extra_functions import school_sizer
hs['size_group'] = hs['hs_total_enrollment'].apply(lambda x: school_sizer(x))
In [7]:
de_by_size = flag_grouper(hs, 'size_group', 'DE')
ap_by_size = flag_grouper(hs, 'size_group', 'AP')

hs_by_size = pd.merge(de_by_size, ap_by_size, on = '# of HS Schools')
hs_by_size = hs_by_size.rename({0: '<100', 1: '100-499', 2:'500-1199', 3:'1200+'})
hs_by_size.index.names = ['HS Student Enrollment']
hs_by_size
Out[7]:
# of HS Schools # Schools Offering DE DE Offering Rate # Schools Offering AP AP Offering Rate
HS Student Enrollment
<100 2361 1331 56.4 333 14.1
100-499 7399 5229 70.7 4103 55.5
500-1199 4548 3413 75.0 4040 88.8
1200+ 4376 3365 76.9 4288 98.0
In [8]:
fig, (ax1,ax2) = plt.subplots(1,2, figsize = (10,4))

plt.sca(ax1)
hs_by_size.plot.bar(y = 'DE Offering Rate', ax = ax1)
plt.xticks(rotation = 0)
plt.legend([])
plt.xlabel('')
plt.title('Percentage of Schools Offering DE\nBy Size ')
plt.yticks(np.arange(0,110,10))
plt.xticks([0,1,2,3], ['<100', '100-499', '500-1199', '>1200'])
plt.ylim([0,100])

plt.sca(ax2)
hs_by_size.plot.bar(y = 'AP Offering Rate', ax=ax2)
plt.xticks(rotation = 0)
plt.legend([])
plt.xlabel('')
plt.title('Percentage of Schools Offering AP\nBy Size ')
plt.yticks(np.arange(0,110, 10))
plt.xticks([0,1,2,3], ['<100', '100-499', '500-1199', '>1200'])
plt.ylim([0,100])
Out[8]:
(0, 100)

By School Locale

- Schools were grouped into four categories based on their locale (as defined by the NCES):
    - City: "Territory inside an Urbanized Area and inside a Principal City" 
    - Rural: "Census-defined rural territory"
    - Suburban: "Territory outside a Principal City and inside an Urbanized Area"
    - Town: "Territory inside an Urban Cluster"
In [9]:
"""Creating a Locale Classifer"""
from my_functions.extra_functions import locale_map
hs['locale_group'] = hs['LOCALE15'].map(locale_map)
In [10]:
de_by_locale = flag_grouper(hs, 'locale_group', 'DE')
ap_by_locale = flag_grouper(hs, 'locale_group', 'AP')

hs_by_locale = pd.merge(de_by_locale, ap_by_locale, on = '# of HS Schools')
hs_by_locale = hs_by_locale.rename({0: 'City', 1: 'Rural', 2: 'Suburban', 3: 'Town'})
hs_by_locale.index.names = ['Locale']
hs_by_locale
Out[10]:
# of HS Schools # Schools Offering DE DE Offering Rate # Schools Offering AP AP Offering Rate
Locale
City 4116 2305 56.0 3155 76.7
Rural 7439 5853 78.7 3828 51.5
Suburban 4487 3129 69.7 3929 87.6
Town 2642 2051 77.6 1852 70.1
In [11]:
fig, (ax1,ax2) = plt.subplots(1,2, figsize = (10,4))

plt.sca(ax1)
hs_by_locale.plot.bar(y = 'DE Offering Rate', ax = ax1)
plt.xticks(rotation = 0)
plt.legend([])
plt.xlabel('')
plt.title('Percentage of Schools Offering DE\nBy Locale ')
plt.yticks(np.arange(0,110,10))
# plt.xticks([0,1,2,3], [''])
plt.ylim([0,100])

plt.sca(ax2)
hs_by_locale.plot.bar(y = 'AP Offering Rate', ax=ax2)
plt.xticks(rotation = 0)
plt.legend([])
plt.xlabel('')
plt.title('Percentage of Schools Offering AP\nBy Locale ')
plt.yticks(np.arange(0,110, 10))
# plt.xticks([0,1,2,3], ['<100', '100-499', '500-1199', '>1200'])
plt.ylim([0,100])
Out[11]:
(0, 100)

By School Non-White Student Percentage

In [12]:
"""Calculate the percent ethnicity of all schools in the set and group schools into quintiles"""
hs['pct_eth'] = (hs['total_enrollment'] - hs['SCH_ENR_WH_F'] - hs['SCH_ENR_WH_M']) / hs['total_enrollment']
from my_functions.extra_functions import eth_grouper
hs['eth_quintile'] = hs['pct_eth'].apply(lambda pct: eth_grouper(pct))
In [13]:
"""What does the distribution of the schools in the dataset look based on ethncitiy?"""
hs.pct_eth.plot.hist(bins=100, xlim = [0,1], edgecolor = 'k')
plt.title('Distribution of Schools by Non-White Percentages')
plt.xlabel('Ethnicity Percentage')
# plt.savefig(fname = './Visualizations/By_ethnicity_dist_200.png', dpi = 200)
Out[13]:
Text(0.5,0,'Ethnicity Percentage')
In [14]:
de_by_eth = flag_grouper(hs, 'eth_quintile', 'DE')
ap_by_eth = flag_grouper(hs, 'eth_quintile', 'AP')

hs_by_eth = pd.merge(de_by_eth, ap_by_eth, on = '# of HS Schools')
hs_by_eth = hs_by_eth.rename({0: '0-20%', 1: '21-40%', 2: '41-60%', 3: '61-80%', 4: '81-100%'})
hs_by_eth.index.names = ['Non-White %']
hs_by_eth
Out[14]:
# of HS Schools # Schools Offering DE DE Offering Rate # Schools Offering AP AP Offering Rate
Non-White %
0-20% 7123 5677 79.7 4386 61.6
21-40% 3506 2685 76.6 2494 71.1
41-60% 2416 1757 72.7 1828 75.7
61-80% 1826 1193 65.3 1367 74.9
81-100% 3813 2026 53.1 2689 70.5
In [15]:
fig, (ax1, ax2) = plt.subplots(1,2, figsize = (10,4))
plt.sca(ax2)
hs_by_eth.plot.bar(y = 'AP Offering Rate', ax = ax2)
plt.legend([])
plt.title('Percentage of Schools with AP\nBy Ethnicity Percentage Quintiles')
plt.xticks(rotation = 0)
plt.yticks(np.arange(0,110,10))
plt.ylim([0,100])
plt.xlabel('')

plt.sca(ax1)
hs_by_eth.plot.bar(y = 'DE Offering Rate', ax = ax1)
plt.legend([])
plt.title('Percentage of Schools with DE\nBy Ethnicity Percentage Quintiles')
plt.xticks(rotation = 0)
plt.yticks(np.arange(0,110,10))
plt.ylim([0,100])
plt.xlabel('')
Out[15]:
Text(0.5,0,'')

What is the locale distribution of the very white schools (0 - 20% non-white students)?

In [16]:
"""Very high percentage non-minority schools by Locale"""
eth_group1_locales = hs[hs.eth_quintile == 1].groupby('locale_group')['LEAID'].count().reset_index()
eth_group1_locales['pct'] = round(eth_group1_locales['LEAID'] / eth_group1_locales['LEAID'].sum() * 100, 1)
eth_group1_locales = eth_group1_locales.set_index('locale_group')

with plt.rc_context({'lines.linewidth': 5, 'font.weight':'bold', 'font.size':11}):
    eth_group1_locales.plot.pie(y='LEAID',autopct='%1.1f%%', 
                            startangle = 55, shadow = True, explode = [.05 for i in range(4)],
                            colormap='Pastel2', figsize = (5,5))
    plt.title('High Schools with <20% non-white students by locale')
    plt.legend([])
    plt.ylabel('')
    plt.xticks(fontdict={'fontweight':'bold'})
    plt.axis('equal')

By School Vocational Status

In [17]:
de_by_voc = flag_grouper(hs, 'SCH_TYPE', 'DE')
ap_by_voc = flag_grouper(hs, 'SCH_TYPE', 'AP')

hs_by_voc = pd.merge(de_by_voc, ap_by_voc, on = '# of HS Schools')
hs_by_voc = hs_by_voc.rename({0: 'Regular', 1: 'Vocational'})
hs_by_voc.index.names = ['School Type']
hs_by_voc
Out[17]:
# of HS Schools # Schools Offering DE DE Offering Rate # Schools Offering AP AP Offering Rate
School Type
Regular 18325 13132 71.7 12647 69.0
Vocational 359 206 57.4 117 32.6
In [18]:
fig, (ax1, ax2) = plt.subplots(1,2, figsize = (10,4))
plt.sca(ax1)
hs_by_voc.plot.bar(y = 'DE Offering Rate', ax = ax1)
plt.legend([])
plt.title('Percentage of Schools with DE\nBy Vocational Status')
plt.xticks(rotation = 0)
plt.yticks(np.arange(0,110,10))
plt.ylim([0,100])
plt.xlabel('')

plt.sca(ax2)
hs_by_voc.plot.bar(y = 'AP Offering Rate', ax = ax2)
plt.legend([])
plt.title('Percentage of Schools with AP\nBy Vocational Status')
plt.xticks(rotation = 0)
plt.yticks(np.arange(0,110,10))
plt.ylim([0,100])
plt.xlabel('')
Out[18]:
Text(0.5,0,'')

ScatterGeo

- Consult the ScatterGeo .png file to see the output.
In [19]:
# """Map the DE Flags to Values for the ScatterGeo Plot"""
# de_map = {'Yes':1, 'No':0}
# dual_enroll_bin = hs.SCH_DUAL_IND.map(de_map)

# scl = [ [0,"rgb(5, 10, 172)"], [1,"rgb(0, 200, 100)"] ]


# data = [ dict(
#         type = 'scattergeo',
#         locationmode = 'USA-states',
#         lon = hs['LON1516'],
#         lat = hs['LAT1516'],
#         mode = 'markers',
#         marker = dict(
#             size = 5,
#             opacity = 0.8,
#             autocolorscale = False,
#             line = dict(
#                 width=1,
#                 color='rgba(255,255,255,1)'
#             ),
#             colorscale = scl,
#             cmin = 0,
#             color = dual_enroll_bin,
#             cmax = 1,
#         ))]

# layout = dict(
#         geo = dict(
#             scope='usa',
#             projection=dict( type='albers usa' ),
            
#         ),
#     )

# fig = dict( data=data, layout=layout )
# iplot(fig)
# # iplot(fig, image = 'png', filename = '02_ScatterGeo_DE_1516', image_width = 2750, image_height=2500)

# print("To see the scattergeo, uncomment code and change the size of the markers (to 3-5) -- Very cumbersome Graph")

By State

- Sorted by DE Offering Rate in Descending Order
In [20]:
de_by_state = flag_grouper(hs, 'LEA_STATE', 'DE', True)
ap_by_state = flag_grouper(hs, 'LEA_STATE', 'AP')

hs_by_state = pd.merge(de_by_state, ap_by_state, on = '# of HS Schools')
hs_by_state = hs_by_state.set_index('LEA_STATE')
hs_by_state.index.names = ['State']
hs_by_state.sort_values('DE Offering Rate', ascending=False)
Out[20]:
# of HS Schools # Schools Offering DE DE Offering Rate # Schools Offering AP AP Offering Rate
State
IA 330 321 97.3 168 50.9
SC 229 212 92.6 186 81.2
HI 64 58 90.6 53 82.8
HI 64 58 90.6 42 65.6
GA 423 381 90.1 377 89.1
VA 321 287 89.4 299 93.1
NM 166 148 89.2 79 47.6
VT 64 57 89.1 53 82.8
VT 64 57 89.1 42 65.6
FL 566 504 89.0 482 85.2
MO 549 481 87.6 223 40.6
LA 313 273 87.2 196 62.6
ID 153 133 86.9 60 39.2
TX 1488 1292 86.8 1079 72.5
ND 157 136 86.6 35 22.3
KS 331 280 84.6 94 28.4
NE 259 219 84.6 67 25.9
AL 355 300 84.5 228 64.2
SD 155 130 83.9 62 40.0
IN 378 317 83.9 328 86.8
MI 675 562 83.3 448 66.4
TN 352 292 83.0 202 57.4
KY 232 191 82.3 202 87.1
MD 218 177 81.2 200 91.7
CO 360 288 80.0 230 63.9
UT 156 123 78.8 106 67.9
WI 481 373 77.5 394 81.9
IL 671 518 77.2 441 65.7
AR 274 211 77.0 256 93.4
WY 76 58 76.3 29 38.2
OH 897 683 76.1 501 55.9
MS 263 194 73.8 161 61.2
NC 537 386 71.9 424 79.0
WV 121 86 71.1 109 90.1
DE 36 25 69.4 30 83.3
OK 445 309 69.4 240 53.9
MN 432 298 69.0 191 44.2
OR 271 185 68.3 139 51.3
WA 365 235 64.4 262 71.8
NJ 411 264 64.2 378 92.0
PA 677 434 64.1 566 83.6
CT 206 132 64.1 171 83.0
ME 120 73 60.8 100 83.3
NH 90 54 60.0 73 81.1
MT 167 99 59.3 77 46.1
RI 55 31 56.4 44 80.0
MA 351 159 45.3 297 84.6
NV 115 52 45.2 79 68.7
NY 1220 546 44.8 932 76.4
AZ 404 180 44.6 191 47.3
AK 243 97 39.9 42 17.3
CA 1433 488 34.1 1163 81.2
DC 29 6 20.7 28 96.6
In [21]:
de_data = dict(type = 'choropleth',
            locations = hs_by_state.index,
            locationmode = 'USA-states',
            colorscale = [[0.0, 'rgb(255,255,255)'], [.2, 'rgb(255,221,221)'], [.4, 'rgb(255, 200, 200)'], [0.8, 'rgb(255, 50, 50)'], [1.0, 'rgb(180,0,0)']],
            reversescale = False,
            z = hs_by_state['DE Offering Rate'])
de_layout = dict(title = '2015-2016 DE-Offered Percentages',
              geo = {'scope':'usa'})
de_choromap = go.Figure(data = [de_data], layout = de_layout)

iplot(de_choromap)
# iplot(de_choromap, image = 'png', filename='./Visualizations/by_state_de_choropleth')
In [22]:
ap_data = dict(type = 'choropleth',
            locations = hs_by_state.index,
            locationmode = 'USA-states',
            colorscale = [[0.0, 'rgb(255,255,255)'], [.2, 'rgb(255,221,221)'], [.4, 'rgb(255, 200, 200)'], [0.8, 'rgb(255, 50, 50)'], [1.0, 'rgb(180,0,0)']],
            reversescale = False,
            z = hs_by_state['AP Offering Rate'])
ap_layout = dict(title = '2015-2016 AP-Offered Percentages',
              geo = {'scope':'usa'})
ap_choromap = go.Figure(data = [ap_data], layout = ap_layout)

iplot(ap_choromap)
# iplot(ap_choromap, image = 'png', filename='./Visualizations/by_state_ap_choropleth')

Visualizing how well each state does offering AP and/or DE

In [23]:
plt.figure(figsize=(6,6))
plt.scatter(x=hs_by_state['DE Offering Rate'], y=hs_by_state['AP Offering Rate'])
plt.ylim([0,100])
plt.xlim([0,100])
plt.ylabel('%High Schools in State Offering AP')
plt.xlabel('%High Schools in State Offering DE')
plt.yticks(np.arange(0,110,10))
plt.xticks(np.arange(0,110,10))
plt.title('States: AP v DE Offering Rates')
plt.show()

By Region (Accreditation)

- Regions are broken down according to the regional accreditation guidelines.

    - Higher Learning Commission (HLC): Arkansas, Arizona, Colorado, Iowa, Illinois, Indiana, Kansas, Michigan,
      Minnesota, Missouri, North Dakota, Nebraska, New Mexico, Ohio, Oklahoma, South Dakota, Wisconsin, 
      West Virginia, and Wyoming. 

    - Middle States Commission on Higher Education (MSCHE): New York, New Jersey, Pennsylvania, Delaware, 
      Maryland, the District of Columbia.

    - New England Association of Schools and Colleges (NEASC): Connecticut, Maine, Massachusetts, New Hampshire,
      Rhode Island, and Vermont.

    - Northwest Commission on Colleges and Universities (NWCCU): Alaska, Idaho, Montana, Nevada, Oregon, 
      Utah, and Washington. 

    - Southern Association of Colleges and Schools (SACS): Alabama, Florida, Georgia, Kentucky, 
      Louisiana, Mississippi, North Carolina, South Carolina, Tennessee, Texas and Virginia.

    - Western Association of Schools and Colleges (WASC): Hawaii, California 
In [24]:
"""Categorize schools into regions"""
from my_functions.extra_functions import region_mapper
hs['region_accred'] = hs['LEA_STATE'].apply(lambda x: region_mapper(x))
In [25]:
de_by_region = flag_grouper(hs, 'region_accred', 'DE', True)
ap_by_region = flag_grouper(hs, 'region_accred', 'AP')

hs_by_region = pd.merge(de_by_region, ap_by_region, on = '# of HS Schools')
hs_by_region = hs_by_region.set_index('region_accred')
hs_by_region.index.names = ['Regions']
hs_by_region
Out[25]:
# of HS Schools # Schools Offering DE DE Offering Rate # Schools Offering AP AP Offering Rate
Regions
HLC 7161 5598 78.2 4086 57.1
MSCHE 2591 1452 56.0 2134 82.4
NEASC 886 506 57.1 738 83.3
NWCCU 1470 924 62.9 765 52.0
SACS 5079 4312 84.9 3836 75.5
WASC 1497 546 36.5 1205 80.5
In [26]:
fig, (ax1,ax2) = plt.subplots(1,2, figsize = (10,6))

plt.sca(ax1)
hs_by_region.plot.barh(y = 'DE Offering Rate', ax=ax1)
plt.title('Percentage of Schools Offering DE\n by Region (Accreditation)')
plt.yticks(rotation = 0)
plt.legend([])
plt.xticks(np.arange(0,110,10))
plt.xlim([0,100])
plt.ylabel('')

plt.sca(ax2)
hs_by_region.plot.barh(y = 'AP Offering Rate', ax=ax2)
plt.title('Percentage of Schools Offering AP\n by Region (Accreditation)')
plt.yticks(rotation = 0)
plt.legend([])
plt.xticks(np.arange(0,110,10))
plt.xlim([0,100])
plt.ylabel('')
plt.tight_layout()

By Region (Census)

- Regions are broken down according to the regional accreditation guidelines.

    - New England - Connecticut, Maine, Massachusetts, New Hampshire, Rhode Island, and Vermont
    - Mid-Atlantic - New Jersey, New York, and Pennsylvania
    - East North Central - Illinois, Indiana, Michigan, Ohio, and Wisconsin
    - West North Central - Iowa, Kansas, Minnesota, Missouri, Nebraska, North Dakota, and South Dakota
    - South Atlantic - Delaware, Florida, Georgia, Maryland, North Carolina, South Carolina, 
      Virginia, District of Columbia, and West Virginia
    - East South Central - Alabama, Kentucky, Mississippi, and Tennessee
    - West South Central - Arkansas, Louisiana, Oklahoma, and Texas
    - Mountain - Arizona, Colorado, Idaho, Montana, Nevada, New Mexico, Utah, and Wyoming
    - Pacific - Alaska, California, Hawaii, Oregon, and Washington
In [27]:
"""Categorize schools into regions"""
from my_functions.extra_functions import region_mapper_census
hs['region_census'] = hs['LEA_STATE'].apply(lambda x: region_mapper_census(x))
In [28]:
de_by_region_census = flag_grouper(hs, 'region_census', 'DE', True)
ap_by_region_census = flag_grouper(hs, 'region_census', 'AP')

hs_by_region_census = pd.merge(de_by_region_census, ap_by_region_census, on = '# of HS Schools')
hs_by_region_census = hs_by_region_census.set_index('region_census')
hs_by_region_census.index.names = ['Regions']
hs_by_region_census
Out[28]:
# of HS Schools # Schools Offering DE DE Offering Rate # Schools Offering AP AP Offering Rate
Regions
East North Central 3102 2453 79.1 2112 68.1
East South Central 1202 977 81.3 793 66.0
Middle Atlantic 2308 1244 53.9 1876 81.3
Mountain 1597 1081 67.7 851 53.3
New England 886 506 57.1 738 83.3
Pacific 2376 1063 44.7 1648 69.4
South Atlantic 2480 2064 83.2 2135 86.1
West North Central 2213 1865 84.3 840 38.0
West South Central 2520 2085 82.7 1771 70.3
In [29]:
fig, (ax1,ax2) = plt.subplots(1,2, figsize = (10,6))

plt.sca(ax1)
hs_by_region_census.plot.barh(y = 'DE Offering Rate', ax=ax1)
plt.title('Percentage of Schools Offering DE\n by Region (Census)')
plt.yticks(rotation = 0)
plt.legend([])
plt.xticks(np.arange(0,110,10))
plt.xlim([0,100])
plt.ylabel('')

plt.sca(ax2)
hs_by_region_census.plot.barh(y = 'AP Offering Rate', ax=ax2)
plt.title('Percentage of Schools Offering AP\n by Region (Census)')
plt.yticks(rotation = 0)
plt.legend([])
plt.xticks(np.arange(0,110,10))
plt.xlim([0,100])
plt.ylabel('')
plt.tight_layout()

By Region (NACEP)

- Regions are broken down according to the regional accreditation guidelines.
    - 1 - New York, New Jersey, Pennslyvania, Delware, Maryland, Washington DC, Connecticut, Maine,
          Massachusettes, New Hampshire, Rhode Island, Vermont, Virginia
    - 2 - Michigan, Indiana, Ohio, West Virigina, Kentukcy, Tennessee, North Carolina, South Carolina,
          Alabama, Mississippi, Georgia, Florida
    - 3 - Illinois, Missouri, Arkansas, Louisiana, Oklahoma, Kansas, Texas
    - 4 - Montana, Idaho, Wyoming, North Dakota, South Dakota, Nebraska, Iowa, Minnesota, Wisconsin
    - 5 - Oregan, Washington, California, Nevada, Utah, Arizona, Colorado, New Mexico, Alaska, Hawaii
In [30]:
"""Categorize schools into regions"""
from my_functions.extra_functions import region_mapper_nacep
hs['region_nacep'] = hs['LEA_STATE'].apply(lambda x: region_mapper_nacep(x))
In [31]:
de_by_region_nacep = flag_grouper(hs, 'region_nacep', 'DE', True)
ap_by_region_nacep = flag_grouper(hs, 'region_nacep', 'AP')

hs_by_region_nacep = pd.merge(de_by_region_nacep, ap_by_region_nacep, on = '# of HS Schools')
hs_by_region_nacep = hs_by_region_nacep.set_index('region_nacep')
hs_by_region_nacep.index.names = ['Regions']
hs_by_region_nacep
Out[31]:
# of HS Schools # Schools Offering DE DE Offering Rate # Schools Offering AP AP Offering Rate
Regions
1 3798 2245 59.1 3171 83.5
2 5028 4108 81.7 3648 72.6
3 4071 3364 82.6 2529 62.1
4 2210 1767 80.0 1083 49.0
5 3577 1854 51.8 2333 65.2
In [32]:
fig, (ax1,ax2) = plt.subplots(1,2, figsize = (10,6))

plt.sca(ax1)
hs_by_region_nacep.plot.barh(y = 'DE Offering Rate', ax=ax1)
plt.title('Percentage of Schools Offering DE\n by Region (NACEP)')
plt.yticks(rotation = 0)
plt.legend([])
plt.xticks(np.arange(0,110,10))
plt.xlim([0,100])
plt.ylabel('')

plt.sca(ax2)
hs_by_region_nacep.plot.barh(y = 'AP Offering Rate', ax=ax2)
plt.title('Percentage of Schools Offering AP\n by Region (NACEP)')
plt.yticks(rotation = 0)
plt.legend([])
plt.xticks(np.arange(0,110,10))
plt.xlim([0,100])
plt.ylabel('')
plt.tight_layout()