IST718 | LAB 3 | NCAA D1 FOOTBALL MAP

01-22-20

In [71]:
import plotly
import plotly.graph_objects as go
In [72]:
import pandas as pd
df = pd.read_csv('ncaa_wikipedia.csv')
In [73]:
df
Out[73]:
Team Nickname City State Unnamed: 4 Current Former First Joined
0 Air Force Falcons Colorado Springs Colorado 4,237 Mountain West WAC 1955 NaN
1 Akron Zips Akron Ohio 19,200 MAC OAC, MCC, OVC 1891 1987
2 Alabama Crimson Tide Tuscaloosa Alabama 38,500 SEC SIAA, SoCon 1892 NaN
3 Appalachian State Mountaineers Boone North Carolina 19,100 Sun Belt NSC, SoCon 1928 2014[n 1]
4 Arizona Wildcats Tucson Arizona 45,200 Pac-12 BIAA, WAC 1899 NaN
... ... ... ... ... ... ... ... ... ...
125 West Virginia Mountaineers Morgantown West Virginia 30,000 Big 12 SoCon, WVIAC, Big East 1891 NaN
126 Western Kentucky Hilltoppers Bowling Green Kentucky 20,300 C-USA SIAA, KIAC, OVC, MVFC, Sun Belt 1913 2009
127 Western Michigan Broncos Kalamazoo Michigan 22,900 MAC MCC 1905 NaN
128 Wisconsin Badgers Madison Wisconsin 44,400 Big Ten NaN 1889 NaN
129 Wyoming Cowboys Laramie Wyoming 12,400 Mountain West Colorado Football Association, RMAC, WAC 1893 NaN

130 rows × 9 columns

In [74]:
counts = pd.DataFrame(df['State'].value_counts())
In [75]:
counts.reset_index(inplace=True)
In [76]:
counts.columns = ['state', 'num_teams']
In [77]:
us_state_abbrev = {
    'Alabama': 'AL',
    'Alaska': 'AK',
    'Arizona': 'AZ',
    'Arkansas': 'AR',
    'California': 'CA',
    'Colorado': 'CO',
    'Connecticut': 'CT',
    'Delaware': 'DE',
    'District of Columbia': 'DC',
    'Florida': 'FL',
    'Georgia': 'GA',
    'Hawaii': 'HI',
    'Idaho': 'ID',
    'Illinois': 'IL',
    'Indiana': 'IN',
    'Iowa': 'IA',
    'Kansas': 'KS',
    'Kentucky': 'KY',
    'Louisiana': 'LA',
    'Maine': 'ME',
    'Maryland': 'MD',
    'Massachusetts': 'MA',
    'Michigan': 'MI',
    'Minnesota': 'MN',
    'Mississippi': 'MS',
    'Missouri': 'MO',
    'Montana': 'MT',
    'Nebraska': 'NE',
    'Nevada': 'NV',
    'New Hampshire': 'NH',
    'New Jersey': 'NJ',
    'New Mexico': 'NM',
    'New York': 'NY',
    'North Carolina': 'NC',
    'North Dakota': 'ND',
    'Northern Mariana Islands':'MP',
    'Ohio': 'OH',
    'Oklahoma': 'OK',
    'Oregon': 'OR',
    'Palau': 'PW',
    'Pennsylvania': 'PA',
    'Puerto Rico': 'PR',
    'Rhode Island': 'RI',
    'South Carolina': 'SC',
    'South Dakota': 'SD',
    'Tennessee': 'TN',
    'Texas': 'TX',
    'Utah': 'UT',
    'Vermont': 'VT',
    'Virgin Islands': 'VI',
    'Virginia': 'VA',
    'Washington': 'WA',
    'West Virginia': 'WV',
    'Wisconsin': 'WI',
    'Wyoming': 'WY',
}
In [78]:
counts['abbrev'] = counts.apply(lambda x: us_state_abbrev[x['state']], axis=1)
In [79]:
fig = go.Figure(data=go.Choropleth(
    locations=counts['abbrev'], 
    z = counts['num_teams'].astype(float), 
    locationmode = 'USA-states', 
    colorscale = 'Reds',
    colorbar_title = "Number of Teams",
))

fig.update_layout(
    title_text = 'Number of Teams in NCAA in D1 FBS',
    geo_scope='usa',
)

fig.show()
In [ ]: