Component 2: Interactive, Bespoke Visualization

Concept: What is the distribution of IMLS grants, and what do these grants do?

Your second dataset will be the IMLS discretionary grants database. These grants include information about the topic of the grant, the institution that received it, its duration, and a few other pieces of data. You may also find useful and interesting data (especially related to zip codes and economic factors) at FRED.

Your visualization should be interactive. There are several frameworks you can use to do this. The three that we have discussed in detail in class have been using the IPython widgets interface to build small, exploratory visualizations, the Bokeh framework and Plotly. You may not use Tableau to build this visualization. If there is another framework you would like to use, please ask.

A few of the concepts that you may explore:

  1. What types of grants are supported by IMLS?

  2. How are these grants distributed across the United States? Are they particularly clustered in certain states?

  3. Is there a relationship between the economic factors in a zip code and the grants from IMLS?

Generate from this data either a notebook that can be executed, a python script that can be executed, or a plotly dashboard that can be accessed. If you utilize plotly, at lease some of the plotly setup must be in a python script.


In [1]:
#import packages
%matplotlib inline
import matplotlib.pyplot as plt
import csv
import numpy as np
import pandas as pd
import collections
import plotly
import plotly.plotly as py
import plotly.graph_objs as go
from plotly.graph_objs import *
plotly.tools.set_credentials_file(username='alexbear', api_key='L6m9DmfDjqrksfHtUH5j')
#plotly.tools.set_credentials_file(username='jlwang233', api_key='hBFucEx4GrL7V9xxFhx0')
#plotly.tools.set_credentials_file(username='lis590dv', api_key='0jCaIttf2QaVJ3lRZZlK')
#plotly.tools.set_credentials_file(username='jxljiang221', api_key='RgXxTYxCam4vBca8DHDq')
#plotly.tools.set_credentials_file(username='jxljiang221', api_key='LOONcFbgZszSxdiuB3Kn')

In [16]:
#Q2-1 BY YINGJUN GUAN
plt.rcParams["figure.figsize"] = (15, 8)
df2 = pd.read_csv("DiscGrants96to13.csv",encoding='iso-8859-1')
cc=collections.Counter(df2["ProgramType"])
vv=[]
kk=[]
for v,k in sorted(cc.items(), key=lambda i: i[1], reverse=True):
    vv.append(v)
    kk.append(k)
    
objects = vv
y_pos = np.arange(len(objects))
performance = kk
 
plt.bar(y_pos, performance, align='center', alpha=0.5)
plt.xticks(y_pos, objects)
plt.ylabel('Number of grants')
plt.xlabel('Type of programs')
plt.title('Program types vs their counts')
 
plt.show()



In [3]:
sum(performance)


Out[3]:
13218

In [4]:
performance


Out[4]:
[3741,
 1731,
 1673,
 1397,
 1299,
 1121,
 846,
 388,
 220,
 198,
 168,
 102,
 91,
 71,
 64,
 57,
 51]

Q2-1

We firstly study the distribution of program types. From the histogram we can see that LG(National Leadership Grants) contributes to the most count of grants, 3741, which is 28.3% of total grants. IL(Museum Leadership Initiatives) and LE(Native American Enhancement Grants) has the least number of grants, 57 and 51 respectively.


In [5]:
df2.head()


Out[5]:
LogNumber Institution Program ProgramType ProjectTitle ProjectType AwardDate InstAddr1 InstAddr2 InstAddr3 ... Longitude FIPSState FIPSCounty CensusTract CensusBlock FIPSMCDCode FIPSPlaceCode CBSACode MetroDivisionCode Description
0 IA-00-00-0001-00 Museum of the Aleutians Conservation Assessment Prog. IA NaN NaN 3/30/2000 P.O. Box 648 NaN NaN ... -166.536862 2.0 16.0 200.0 2014.0 1615.0 80770.0 NaN NaN NaN
1 IA-00-00-0002-00 Depot Museum, Inc. Conservation Assessment Prog. IA NaN NaN 3/30/2000 P.O. Box 681420 NaN NaN ... -85.694757 1.0 49.0 961000.0 2013.0 91206.0 27616.0 NaN NaN NaN
2 IA-00-00-0003-00 National Voting Rights Museum and Institute Conservation Assessment Prog. IA NaN NaN 3/30/2000 6 Highway 80 East NaN NaN ... -87.017024 1.0 47.0 957200.0 1005.0 92883.0 NaN 42820.0 NaN NaN
3 IA-00-00-0004-00 Bob Jones Museum Conservation Assessment Prog. IA NaN NaN 3/30/2000 P.O. Box 613 NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
4 IA-00-00-0005-00 Coronado Museum of History and Art Conservation Assessment Prog. IA NaN NaN 3/30/2000 1100 Orange Avenue NaN NaN ... -117.170703 6.0 73.0 10900.0 1021.0 92780.0 16378.0 41740.0 NaN NaN

5 rows × 43 columns


In [6]:
df3=df2[(df2["Longitude"]>-95)&(df2["Latitude"]<24)]
#df2=df2[(((df2["Longitude"]>-95)&(df2["Latitude"]<24))==False)]
df2=df2[((df2["InstState"]=="GU")|(df2["InstState"]=="PW")|(df2["InstState"]=="VI")|(df2["InstState"]=="PR")|(df2["InstState"]=="MP")|(df2["InstState"]=="FM")|(df2["InstState"]=="MH")|(df2["InstState"]=="AS")|(df2["InstState"]==""))==False]

In [7]:
df2.describe


Out[7]:
<bound method NDFrame.describe of               LogNumber                                        Institution  \
0      IA-00-00-0001-00                            Museum of the Aleutians   
1      IA-00-00-0002-00                                 Depot Museum, Inc.   
2      IA-00-00-0003-00        National Voting Rights Museum and Institute   
3      IA-00-00-0004-00                                   Bob Jones Museum   
4      IA-00-00-0005-00                 Coronado Museum of History and Art   
5      IA-00-00-0006-00            Hayward Area Historical  Society Museum   
6      IA-00-00-0007-00                                        Sun Gallery   
7      IA-00-00-0008-00                Coachella Valley Historical Society   
8      IA-00-00-0009-00                                   Los Gatos Museum   
9      IA-00-00-0010-00                                 Gold Nugget Museum   
10     IA-00-00-0011-00                   Kimberly Crest House and Gardens   
11     IA-00-00-0012-00           Maritime Museum Association of San Diego   
12     IA-00-00-0013-00                        Los Angeles Maritime Museum   
13     IA-00-00-0014-00                           Discovery Science Museum   
14     IA-00-00-0015-00               Santa Ynez Valley Historical Society   
15     IA-00-00-0016-00                                Fort Collins Museum   
16     IA-00-00-0017-00                              Golden Pioneer Museum   
17     IA-00-00-0018-00                           Housatonic Museum of Art   
18     IA-00-00-0019-00                           Guilford Keeping Society   
19     IA-00-00-0020-00       Northeast States Civilian Conservation Corps   
20     IA-00-00-0021-00               Southbury Historical Society Museums   
21     IA-00-00-0022-00                            Arts Club of Washington   
22     IA-00-00-0023-00                         National Children's Museum   
23     IA-00-00-0024-00                                   Barnacle Society   
24     IA-00-00-0025-00                           Museum of the Everglades   
25     IA-00-00-0026-00                Key West Art and Historical Society   
26     IA-00-00-0027-00                          Augusta Museum of History   
27     IA-00-00-0028-00                           Brunswick History Museum   
28     IA-00-00-0029-00                            Savannah History Museum   
29     IA-00-00-0030-00                St. Simons Island Lighthouse Musuem   
...                 ...                                                ...   
13188  MA-02-04-0505-04                     Mildred Lane Kemper Art Museum   
13189  LG-20-03-0190-03                               Museum of Modern Art   
13190  LG-05-09-0041-09           President and Fellows of Harvard College   
13191  MA-03-04-0688-04                       Santa Barbara Botanic Garden   
13192  LG-07-09-0095-09     Association of Southeastern Research Libraries   
13193  MA-02-04-0267-04           Eastern State Penitentiary Historic Site   
13194  MA-02-04-0196-04                          Yeshiva University Museum   
13195  MA-03-04-0063-04                       Children's Museum at Holyoke   
13196  LG-40-05-0283-05                  Nebraska State Historical Society   
13197  MA-01-04-0662-04                   New Hampshire Historical Society   
13198  LG-30-04-0204-04                                 Cornell University   
13199  MA-01-04-0549-04            Henry Francis du Pont Winterthur Museum   
13200  MA-02-04-0013-04                     William Hammond Mathers Museum   
13201  LG-40-05-0383-05                      Haines Borough Public Library   
13202  LG-20-03-0184-03                          Oriental Institute Museum   
13203  LG-40-05-0298-05                   Fairbanks Museum and Planetarium   
13204  MA-02-04-0200-04                        MIT List Visual Arts Center   
13205  LG-05-05-0220-05                        WGBH Educational Foundation   
13206  ST-03-03-0001-03                   Suffolk County Vanderbilt Museum   
13207  LG-30-04-0261-04  University of California, Los Angeles, Near Ea...   
13208  MA-01-05-0010-05                            Desert Botanical Garden   
13209  RE-06-05-0014-05                                 Indiana University   
13210  LG-06-09-0174-09                          University of North Texas   
13211  MA-02-05-0087-05                          Jewish Museum of Maryland   
13212  MA-01-05-0050-05              Historical Museum of Southern Florida   
13213  MA-01-05-0003-05       California Indian Museum and Cultural Center   
13214  MA-02-06-0434-06             Gifford Arboretum, University of Miami   
13215  LG-06-09-0198-09  Regents of the University of California, Lawre...   
13216  MA-02-06-0439-06                        Louisiana Museum Foundation   
13217  MA-03-06-0437-06                           Contemporary Arts Center   

                               Program ProgramType  \
0        Conservation Assessment Prog.          IA   
1        Conservation Assessment Prog.          IA   
2        Conservation Assessment Prog.          IA   
3        Conservation Assessment Prog.          IA   
4        Conservation Assessment Prog.          IA   
5        Conservation Assessment Prog.          IA   
6        Conservation Assessment Prog.          IA   
7        Conservation Assessment Prog.          IA   
8        Conservation Assessment Prog.          IA   
9        Conservation Assessment Prog.          IA   
10       Conservation Assessment Prog.          IA   
11       Conservation Assessment Prog.          IA   
12       Conservation Assessment Prog.          IA   
13       Conservation Assessment Prog.          IA   
14       Conservation Assessment Prog.          IA   
15       Conservation Assessment Prog.          IA   
16       Conservation Assessment Prog.          IA   
17       Conservation Assessment Prog.          IA   
18       Conservation Assessment Prog.          IA   
19       Conservation Assessment Prog.          IA   
20       Conservation Assessment Prog.          IA   
21       Conservation Assessment Prog.          IA   
22       Conservation Assessment Prog.          IA   
23       Conservation Assessment Prog.          IA   
24       Conservation Assessment Prog.          IA   
25       Conservation Assessment Prog.          IA   
26       Conservation Assessment Prog.          IA   
27       Conservation Assessment Prog.          IA   
28       Conservation Assessment Prog.          IA   
29       Conservation Assessment Prog.          IA   
...                                ...         ...   
13188              Museums for America          MA   
13189       National Leadership Grants          LG   
13190       National Leadership Grants          LG   
13191              Museums for America          MA   
13192       National Leadership Grants          LG   
13193              Museums for America          MA   
13194              Museums for America          MA   
13195              Museums for America          MA   
13196       National Leadership Grants          LG   
13197              Museums for America          MA   
13198       National Leadership Grants          LG   
13199              Museums for America          MA   
13200              Museums for America          MA   
13201       National Leadership Grants          LG   
13202       National Leadership Grants          LG   
13203       National Leadership Grants          LG   
13204              Museums for America          MA   
13205       National Leadership Grants          LG   
13206         Save America's Treasures          ST   
13207       National Leadership Grants          LG   
13208              Museums for America          MA   
13209  Librarians for the 21st Century          RE   
13210       National Leadership Grants          LG   
13211              Museums for America          MA   
13212              Museums for America          MA   
13213              Museums for America          MA   
13214              Museums for America          MA   
13215       National Leadership Grants          LG   
13216              Museums for America          MA   
13217              Museums for America          MA   

                                            ProjectTitle  \
0                                                    NaN   
1                                                    NaN   
2                                                    NaN   
3                                                    NaN   
4                                                    NaN   
5                                                    NaN   
6                                                    NaN   
7                                                    NaN   
8                                                    NaN   
9                                                    NaN   
10                                                   NaN   
11                                                   NaN   
12                                                   NaN   
13                                                   NaN   
14                                                   NaN   
15                                                   NaN   
16                                                   NaN   
17                                                   NaN   
18                                                   NaN   
19                                                   NaN   
20                                                   NaN   
21                                                   NaN   
22                                                   NaN   
23                                                   NaN   
24                                                   NaN   
25                                                   NaN   
26                                                   NaN   
27                                                   NaN   
28                                                   NaN   
29                                                   NaN   
...                                                  ...   
13188                         Collections Access Project   
13189         Development of a True Color Imaging System   
13190  A Policy Based Archival Replication System for...   
13191           Lake Casitas Watershed Education Program   
13192     ASERL Collaborative Federal Depository Project   
13193  Expanding Educational Sources: New Programming...   
13194    Public Programming Capacity Building Initiative   
13195  At The Canal's Edge: A Community Exhibit Devel...   
13196  Saving Nebraska's Treasurers: Preventive Conse...   
13197            Documenting Decorative Arts Collections   
13198  Digital Library of Printable Machines: Models ...   
13199  Re-Cataloging of Furniture and Prints and Pain...   
13200                                   What is Culture?   
13201              Perspectives: Issues and Explorations   
13202  This History, Our History:  Ancient Mesopotami...   
13203  Eye On the Night Sky: A Partnership for Scienc...   
13204                              Beyond 20 Ames Street   
13205  WGBH Media Library and Archives Digital Librar...   
13206  Suffolk County Vanderbilt Museum "Diorama Hall...   
13207                                   Discover Babylon   
13208  Sonoran Passport: Plants and People of the Son...   
13209  An OBE Online Course for Library and Museum Pe...   
13210  Classification of Government Websites in the E...   
13211  Core Exhibition for the Jewish Museum of Maryland   
13212  Historical Museum of Southern Florida Collecti...   
13213  Storytelling Technology Outreach and Real-Time...   
13214  Lifelong Learning Project Needs Created by the...   
13215  Advancing Optical Scanning of Mechanical Sound...   
13216  Louisiana State Museum Educational Development...   
13217  Rebuilding and Renewal of the Arts in New Orleans   

                                            ProjectType  AwardDate  \
0                                                   NaN  3/30/2000   
1                                                   NaN  3/30/2000   
2                                                   NaN  3/30/2000   
3                                                   NaN  3/30/2000   
4                                                   NaN  3/30/2000   
5                                                   NaN  3/30/2000   
6                                                   NaN  3/30/2000   
7                                                   NaN  3/30/2000   
8                                                   NaN  3/30/2000   
9                                                   NaN  3/30/2000   
10                                                  NaN  3/30/2000   
11                                                  NaN  3/30/2000   
12                                                  NaN  3/30/2000   
13                                                  NaN  3/30/2000   
14                                                  NaN  3/30/2000   
15                                                  NaN  3/30/2000   
16                                                  NaN  3/30/2000   
17                                                  NaN  3/30/2000   
18                                                  NaN  3/30/2000   
19                                                  NaN  3/30/2000   
20                                                  NaN  3/30/2000   
21                                                  NaN  3/30/2000   
22                                                  NaN  3/30/2000   
23                                                  NaN  3/30/2000   
24                                                  NaN  3/30/2000   
25                                                  NaN  3/30/2000   
26                                                  NaN  3/30/2000   
27                                                  NaN  3/30/2000   
28                                                  NaN  3/30/2000   
29                                                  NaN  3/30/2000   
...                                                 ...        ...   
13188                  MFA-Supporting Lifelong Learning  8/24/2004   
13189                                   Museums On-Line  8/22/2003   
13190                                   NLG Library ADR  9/24/2009   
13191    MFA-Serving as Centers of Community Engagement  8/24/2004   
13192                                  NLG Library Demo  9/24/2009   
13193                  MFA-Supporting Lifelong Learning  8/24/2004   
13194                  MFA-Supporting Lifelong Learning  8/24/2004   
13195    MFA-Serving as Centers of Community Engagement  8/24/2004   
13196  NLG-Partnership Nation of Learners Collaboration  8/26/2005   
13197                  MFA-Sustaining Cultural Heritage  8/24/2004   
13198                                           NLG LMC  8/20/2004   
13199                  MFA-Sustaining Cultural Heritage  8/24/2004   
13200                  MFA-Supporting Lifelong Learning  8/24/2004   
13201  NLG-Partnership Nation of Learners Collaboration  8/26/2005   
13202                                   Museums On-Line  8/22/2003   
13203  NLG-Partnership Nation of Learners Collaboration  8/26/2005   
13204                  MFA-Supporting Lifelong Learning  8/24/2004   
13205                                   NLG Library ADR   9/1/2005   
13206                                     ST-collection   6/1/2004   
13207                                           NLG LMC  8/20/2004   
13208                  MFA-Sustaining Cultural Heritage  6/29/2005   
13209                          L21-Continuing Education  1/27/2005   
13210                              NLG Library Research  9/24/2009   
13211                  MFA-Supporting Lifelong Learning  6/29/2005   
13212                  MFA-Sustaining Cultural Heritage  6/29/2005   
13213                  MFA-Sustaining Cultural Heritage  6/29/2005   
13214                  MFA-Supporting Lifelong Learning  3/13/2006   
13215                              NLG Library Research  9/24/2009   
13216                  MFA-Supporting Lifelong Learning  3/13/2006   
13217    MFA-Serving as Centers of Community Engagement  3/13/2006   

                              InstAddr1             InstAddr2 InstAddr3  \
0                          P.O. Box 648                   NaN       NaN   
1                       P.O. Box 681420                   NaN       NaN   
2                     6 Highway 80 East                   NaN       NaN   
3                          P.O. Box 613                   NaN       NaN   
4                    1100 Orange Avenue                   NaN       NaN   
5                     22701 Main Street                   NaN       NaN   
6                         1015 E Street                   NaN       NaN   
7                          P.O. Box 595                   NaN       NaN   
8                         P.O. Box 1904                   NaN       NaN   
9                          P.O. Box 949                   NaN       NaN   
10                         P.O. Box 206                   NaN       NaN   
11              1492 North Harbor Drive                   NaN       NaN   
12                             Berth 84    Foot of 6th Street       NaN   
13               2500 North Main Street                   NaN       NaN   
14                         P.O. Box 181                   NaN       NaN   
15                   200 Mathews Street                   NaN       NaN   
16                      923 10th Street                   NaN       NaN   
17              900 Lafayette Boulevard                   NaN       NaN   
18                         P.O. Box 363                   NaN       NaN   
19               166 Chestnut Hill Road                   NaN       NaN   
20                         P.O. Box 124                   NaN       NaN   
21                    2017 I Street, NW                   NaN       NaN   
22         955 L'Enfant Plaza North, SW                   NaN       NaN   
23                    3845 Main Highway                   NaN       NaN   
24                           P.O. Box 8                   NaN       NaN   
25                     281 Front Street                   NaN       NaN   
26                  560 Reynolds Street                   NaN       NaN   
27                    1327 Union Street                   NaN       NaN   
28     303 Martin Luther King Jr. Blvd.                   NaN       NaN   
29                       P.O. Box 21136                   NaN       NaN   
...                                 ...                   ...       ...   
13188               One Brookings Drive       Campus Box 1214       NaN   
13189             128 Pierrepont Street                   NaN       NaN   
13190        1350 Massachussetts Avenue                   NaN       NaN   
13191          1212 Mission Canyon Road                   NaN       NaN   
13192                         Box 90182          226A Bostock       NaN   
13193             2124 Fairmount Avenue                   NaN       NaN   
13194               15 West 16th Street                   NaN       NaN   
13195                 444 Dwight Street                   NaN       NaN   
13196                    P.O. Box 82554                   NaN       NaN   
13197                    30 Park Street                   NaN       NaN   
13198                      120 Day hall                   NaN       NaN   
13199                 5105 Kennett Pike                   NaN       NaN   
13200            601 East Eighth Street                   NaN       NaN   
13201                     P.O. Box 1089                   NaN       NaN   
13202             1155 East 58th Street                   NaN       NaN   
13203                  1302 Main Street                   NaN       NaN   
13204               20 Ames St. E15-109                   NaN       NaN   
13205                125 Western Avenue                   NaN       NaN   
13206                      P.O.Box 0605  180 Little Neck Road       NaN   
13207                 351 H Kinsey Hall                   NaN       NaN   
13208         1201 North Galvin Parkway                   NaN       NaN   
13209                       PO Box 1847                   NaN       NaN   
13210       Office of Research Services       P.O. Box 305250       NaN   
13211                   15 Lloyd Street                   NaN       NaN   
13212                  101 West Flagler                   NaN       NaN   
13213                   5250 Aero Drive                   NaN       NaN   
13214              1204 Dickenson Drive              Bldg 37A       NaN   
13215                 One Cyclotron Rd.            MS:50B5239       NaN   
13216               1000 Bourbon Street                 #B429       NaN   
13217                   900 Camp Street                   NaN       NaN   

                             ...                           Longitude  \
0                            ...                         -166.536862   
1                            ...                          -85.694757   
2                            ...                          -87.017024   
3                            ...                                 NaN   
4                            ...                         -117.170703   
5                            ...                         -122.089393   
6                            ...                         -122.089393   
7                            ...                         -116.234704   
8                            ...                         -121.984631   
9                            ...                         -121.595628   
10                           ...                         -117.184497   
11                           ...                         -117.162484   
12                           ...                         -118.290137   
13                           ...                         -117.834190   
14                           ...                         -120.078930   
15                           ...                         -105.074043   
16                           ...                         -105.192561   
17                           ...                          -73.200888   
18                           ...                          -72.686940   
19                           ...                          -72.302395   
20                           ...                          -73.230332   
21                           ...                          -77.041717   
22                           ...                          -77.016695   
23                           ...                          -80.240449   
24                           ...                          -81.382723   
25                           ...                          -81.764001   
26                           ...                          -81.970873   
27                           ...                          -81.492681   
28                           ...                          -81.092398   
29                           ...                          -81.381340   
...                          ...                                 ...   
13188                        ...                          -90.303828   
13189                        ...                          -73.991865   
13190                        ...                          -71.118184   
13191                        ...                         -119.736329   
13192                        ...                          -78.931984   
13193                        ...                          -75.171254   
13194                        ...                          -73.998324   
13195                        ...                          -72.604980   
13196                        ...                          -96.710846   
13197                        ...                          -71.539033   
13198                        ...                          -76.465140   
13199                        ...                          -75.612861   
13200                        ...                          -86.526366   
13201                        ...                         -135.443134   
13202                        ...                          -87.597441   
13203                        ...                          -72.020108   
13204                        ...                          -71.093634   
13205                        ...                          -70.870993   
13206                        ...                          -73.376816   
13207                        ...                         -118.437041   
13208                        ...                         -111.944716   
13209                        ...                          -86.532491   
13210                        ...                          -97.146254   
13211                        ...                          -76.611301   
13212                        ...                          -80.203410   
13213                        ...                         -122.764631   
13214                        ...                          -80.280045   
13215                        ...                         -122.242310   
13216                        ...                          -90.063092   
13217                        ...                          -90.070977   

      FIPSState FIPSCounty  CensusTract  CensusBlock  FIPSMCDCode  \
0           2.0       16.0        200.0       2014.0       1615.0   
1           1.0       49.0     961000.0       2013.0      91206.0   
2           1.0       47.0     957200.0       1005.0      92883.0   
3           NaN        NaN          NaN          NaN          NaN   
4           6.0       73.0      10900.0       1021.0      92780.0   
5           6.0        1.0     435400.0       3003.0      91260.0   
6           6.0        1.0     435400.0       3003.0      91260.0   
7           6.0       65.0      45207.0       1000.0      90520.0   
8           6.0       85.0     507001.0       2059.0      92830.0   
9           6.0        7.0       1900.0       3002.0      92380.0   
10          6.0       71.0       8301.0       2011.0      92770.0   
11          6.0       73.0       5300.0       3001.0      92780.0   
12          6.0       37.0     296902.0       1007.0      91750.0   
13          6.0       59.0      75403.0       1019.0      90050.0   
14          6.0       83.0       1905.0       3041.0      93065.0   
15          8.0       69.0        100.0       2064.0      91330.0   
16          8.0       59.0      10100.0       2004.0      92641.0   
17          9.0        1.0      71300.0       1005.0       8070.0   
18          9.0        9.0     190301.0       2004.0      34950.0   
19          9.0       13.0     890100.0       1000.0      72090.0   
20          9.0        9.0     348124.0       2031.0      69640.0   
21         11.0        1.0      10700.0       1030.0      50000.0   
22         11.0        1.0      10200.0       2043.0      50000.0   
23         12.0       86.0       7103.0       2001.0      92158.0   
24         12.0       21.0      11102.0       2192.0      91027.0   
25         12.0       87.0     971900.0       2005.0      91755.0   
26         13.0      245.0        700.0       2009.0      90168.0   
27         13.0      127.0        900.0       1021.0      90444.0   
28         13.0       51.0        900.0       1060.0      92712.0   
29         13.0      127.0        200.0       3021.0      92658.0   
...         ...        ...          ...          ...          ...   
13188      29.0      189.0     216300.0       1008.0      29818.0   
13189      36.0       47.0        900.0       1001.0      10022.0   
13190      25.0       17.0     353700.0       3005.0      11000.0   
13191       6.0       83.0        502.0       5018.0      92890.0   
13192      37.0       63.0       1501.0       1012.0      90932.0   
13193      42.0      101.0      13500.0       1006.0      60000.0   
13194      36.0       61.0       8100.0       2000.0      44919.0   
13195      25.0       13.0     811700.0       2013.0      30840.0   
13196      31.0      109.0        500.0       1045.0      91753.0   
13197      33.0       13.0      32300.0       1014.0      14200.0   
13198      36.0      109.0       1300.0       2010.0      38088.0   
13199      10.0        3.0      11800.0       2053.0      92960.0   
13200      18.0      105.0       1600.0       3039.0       5878.0   
13201       2.0      100.0        100.0       3009.0      31160.0   
13202      17.0       31.0     836200.0       1016.0      14000.0   
13203      50.0        5.0     957400.0       3010.0      62200.0   
13204      25.0       17.0     353102.0       1004.0      11000.0   
13205      25.0        9.0     203100.0       4013.0      38400.0   
13206      36.0      103.0     110402.0       1004.0      37000.0   
13207       6.0       37.0     265602.0       2004.0      91750.0   
13208       4.0       13.0     111204.0       1010.0      92601.0   
13209      18.0      105.0       1101.0       2008.0      59112.0   
13210      48.0      121.0      21000.0       2002.0      91010.0   
13211      24.0      510.0      40100.0       1000.0      90000.0   
13212      12.0       86.0       3602.0       3008.0      92158.0   
13213       6.0       97.0     152702.0       4027.0      92940.0   
13214      12.0       86.0     980300.0       1005.0      92158.0   
13215       6.0        1.0     400100.0       1016.0      92230.0   
13216      22.0       71.0       3800.0       1018.0      98000.0   
13217      22.0       71.0      13400.0       2093.0      98000.0   

       FIPSPlaceCode  CBSACode MetroDivisionCode  \
0            80770.0       NaN               NaN   
1            27616.0       NaN               NaN   
2                NaN   42820.0               NaN   
3                NaN       NaN               NaN   
4            16378.0   41740.0               NaN   
5            33000.0   41860.0           36084.0   
6            33000.0   41860.0           36084.0   
7            36448.0   40140.0               NaN   
8            44112.0   41940.0               NaN   
9            55520.0   17020.0               NaN   
10           59962.0   40140.0               NaN   
11           66000.0   41740.0               NaN   
12           44000.0   31080.0           31084.0   
13           69000.0   31080.0           11244.0   
14               NaN   42200.0               NaN   
15           27425.0   22660.0               NaN   
16           30835.0   19740.0               NaN   
17            8000.0   14860.0               NaN   
18               NaN   35300.0               NaN   
19           72300.0   25540.0               NaN   
20           37930.0   35300.0               NaN   
21           50000.0   47900.0           47894.0   
22           50000.0   47900.0           47894.0   
23           45000.0   33100.0           33124.0   
24           21425.0   34940.0               NaN   
25           36550.0   28580.0               NaN   
26            4204.0   12260.0               NaN   
27           11560.0   15260.0               NaN   
28           69000.0   42340.0               NaN   
29           68040.0   15260.0               NaN   
...              ...       ...               ...   
13188            NaN   41180.0               NaN   
13189        51000.0   35620.0           35614.0   
13190        11000.0   14460.0           15764.0   
13191        69070.0   42200.0               NaN   
13192        19000.0   20500.0               NaN   
13193        60000.0   37980.0           37964.0   
13194        51000.0   35620.0           35614.0   
13195        30840.0   44140.0               NaN   
13196        28000.0   30700.0               NaN   
13197        14200.0   18180.0               NaN   
13198        22326.0   27060.0               NaN   
13199            NaN   37980.0           48864.0   
13200         5860.0   14020.0               NaN   
13201        31050.0       NaN               NaN   
13202        14000.0   16980.0           16974.0   
13203        62125.0       NaN               NaN   
13204        11000.0   14460.0           15764.0   
13205        38435.0   14460.0           15764.0   
13206        13442.0   35620.0           35004.0   
13207        44000.0   31080.0           31084.0   
13208        55000.0   38060.0               NaN   
13209         5860.0   14020.0               NaN   
13210        19972.0   19100.0           19124.0   
13211         4000.0   12580.0               NaN   
13212        45000.0   33100.0           33124.0   
13213        40426.0   42220.0               NaN   
13214        14250.0   33100.0           33124.0   
13215        53000.0   41860.0           36084.0   
13216        55000.0   35380.0               NaN   
13217        55000.0   35380.0               NaN   

                                             Description  
0                                                    NaN  
1                                                    NaN  
2                                                    NaN  
3                                                    NaN  
4                                                    NaN  
5                                                    NaN  
6                                                    NaN  
7                                                    NaN  
8                                                    NaN  
9                                                    NaN  
10                                                   NaN  
11                                                   NaN  
12                                                   NaN  
13                                                   NaN  
14                                                   NaN  
15                                                   NaN  
16                                                   NaN  
17                                                   NaN  
18                                                   NaN  
19                                                   NaN  
20                                                   NaN  
21                                                   NaN  
22                                                   NaN  
23                                                   NaN  
24                                                   NaN  
25                                                   NaN  
26                                                   NaN  
27                                                   NaN  
28                                                   NaN  
29                                                   NaN  
...                                                  ...  
13188  Purpose: Supporting Lifelong Learning  The Was...  
13189  MoMA is collaborating with The National Galler...  
13190  Working with the Odum Institute for Research (...  
13191  Purpose: Serving as Centers of Community Engag...  
13192  The Association of Southeastern Research Libra...  
13193  Purpose: Supporting Lifelong Learning  The Eas...  
13194  Purpose: Supporting Lifelong Learning  Public ...  
13195  Purpose: Serving as Centers of Community Engag...  
13196  Through a program modeled on the popular publi...  
13197  Purpose: Sustaining Cultural Heritage  The New...  
13198  The Cornell University Library (CUL), in partn...  
13199  Purpose: Sustaining Cultural Heritage  Wintert...  
13200  Purpose: Supporting Lifelong Learning  "What I...  
13201  Perspectives: Issues and Explorations is a two...  
13202  The Oriental Institute, with two university co...  
13203  Eye on the Night Sky: A Project for Science Li...  
13204  Purpose: Supporting Lifelong Learning  In its ...  
13205  The WGBH Media Library will integrate three di...  
13206  We seek to restore and make ADA compliant the ...  
13207  Discover Babylon will research and evaluate ne...  
13208  This grant will enable the garden to refine cu...  
13209  Indiana University (IU), in a Cooperative Agre...  
13210  As the Web becomes the dissemination tool of c...  
13211  The Jewish Museum of Maryland (JMM) will use t...  
13212  The Historical Museum of Southern Florida (HMS...  
13213  The goal of the STORIE project is to preserve,...  
13214  The goal of this project is to enhance the edu...  
13215  Working with the Library of Congress, Lawrence...  
13216  The Louisiana State Museum seeks to provide un...  
13217  We will hire a Consultant to study the new pop...  

[13176 rows x 43 columns]>

In [8]:
#Q2-2a BY XINYU ZHANG
yearly=[] 
state=[]
for year,group in df2.groupby('FiscalYear'):
    print (year)
    df_2=group.groupby('InstState')
#     state=df4['InstState'].unique()
    state.append(df_2.groups)
    total=df_2['AwardTotal'].sum()
    print(total)
    yearly.append(total)
#print(yearly[0])


1996
InstState
AK      95833.0
AL      21315.0
AR     164414.0
AZ     264753.0
CA    1749844.0
CO     552071.0
CT     291004.0
DC     107129.0
DE     387649.0
FL     428138.0
GA     381320.0
HI      34877.0
IA      88955.0
IL     857809.0
IN     234722.0
KS     184225.0
KY     197818.0
LA     174295.0
MA    1858747.0
MD     450698.0
ME     334468.0
MI     705099.0
MN     580732.0
MO     169010.0
MS      10460.0
MT     117775.0
NC     779323.0
ND     101761.0
NE     233085.0
NH     308452.0
NJ     128336.0
NM     119032.0
NV       3950.0
NY    1928777.0
OH     899762.0
OK       6510.0
OR     281356.0
PA    1586867.0
RI      15840.0
SC     506310.0
SD      93618.0
TN     211758.0
TX     306468.0
UT     126072.0
VA     281803.0
VT     177204.0
WA     449297.0
WI     427732.0
WV      10060.0
WY      31315.0
Name: AwardTotal, dtype: float64
1997
InstState
AK     121215.0
AL     243470.0
AR     102324.0
AZ     578131.0
CA    1553503.0
CO     326619.0
CT     733580.0
DC      41175.0
DE      66516.0
FL     755934.0
GA     257027.0
HI     190263.0
IA     200716.0
ID      24480.0
IL    1083416.0
IN     488825.0
KS     136506.0
KY     190844.0
LA     146630.0
MA     818393.0
MD     387797.0
ME     436049.0
MI     602875.0
MN     485995.0
MO     465550.0
MS     151203.0
MT     704270.0
NC     382791.0
ND      31872.0
NE      86232.0
NH     423803.0
NJ      34801.0
NM      93888.0
NV       9330.0
NY    2441179.0
OH     896049.0
OK     121215.0
OR     264637.0
PA    1112695.0
RI     328107.0
SC     117245.0
SD     290257.0
TN      68948.0
TX     629365.0
UT      42453.0
VA     381977.0
VT     274140.0
WA     463772.0
WI     496147.0
WV      41514.0
WY      40853.0
Name: AwardTotal, dtype: float64
1998
InstState
AK     675794.0
AL     120275.0
AR     229021.0
AZ     411147.0
CA    1994152.0
CO     498997.0
CT     191908.0
DC     600221.0
DE     220707.0
FL    1466380.7
GA     399063.0
HI     639942.0
IA     543617.0
ID      13260.0
IL    1268942.0
IN     654464.0
KS     313986.0
KY     182254.0
LA     114137.0
MA    1966356.0
MD     373499.0
ME     289250.0
MI     885172.0
MN     456940.0
MO     704592.0
MS       6775.0
MT     481095.0
NC     977506.0
ND     150784.0
NE     339015.0
NH     280295.0
NJ     136116.0
NM     656686.0
NV     150560.0
NY    3124244.0
OH     539795.0
OK     319501.0
OR     174302.0
PA    2045542.0
RI     422370.0
SC     138202.0
SD     225439.0
TN     133486.0
TX     894864.0
UT     257662.0
VA     854711.0
VT     412469.0
WA     815348.0
WI     741080.0
WV     126178.0
WY       1775.0
Name: AwardTotal, dtype: float64
1999
InstState
AK      694357.0
AL      286712.0
AR      196443.0
AZ     1203359.0
CA     3433451.0
CO     1058635.0
CT     1028871.0
DC      126504.0
DE      450388.0
FL      635251.0
GA      708995.0
HI      468709.0
IA      753727.0
ID      795805.0
IL     2870932.0
IN      535997.0
KS      331583.0
KY      242150.0
LA      423403.0
MA     1624269.0
MD      941793.0
ME      646181.0
MI      638918.0
MN      748965.0
MO      692524.0
MS        6275.0
MT      254103.0
NC     1068704.0
ND      155367.0
NE      220535.0
NH      269986.0
NJ      194597.0
NM      291700.0
NV       35500.0
NY     5487423.0
OH      692545.0
OK      466694.0
OR      387052.0
PA    13102321.0
SC      382603.0
SD      330106.0
TN      261497.0
TX      723222.0
UT       90025.0
VA      445659.0
VT      410865.0
WA      470115.0
WI     1434608.0
WV       38942.0
WY       12970.0
Name: AwardTotal, dtype: float64
2000
InstState
AK    1245889.0
AL     239160.0
AR     116639.0
AZ     822782.0
CA    2491062.0
CO     326748.0
CT     416639.0
DC     381947.0
DE       4745.0
FL    1855240.0
GA     737545.0
HI     612335.0
IA     299228.0
ID      24410.0
IL    2955688.0
IN     495035.0
KS     150697.0
KY     354311.0
LA     382108.0
MA    1621607.0
MD     942673.0
ME     136073.0
MI    1247937.0
MN    1339591.0
MO     408152.0
MS     117665.0
MT     810834.0
NC     745682.0
ND      19775.0
NE     503611.0
NH     127819.0
NJ      32103.0
NM     559463.0
NV     286850.0
NY    3301860.0
OH    1275318.0
OK     380096.0
OR     164660.0
PA    2199473.0
RI     372721.0
SC     451397.0
SD     215674.0
TN     709104.0
TX    1751331.0
UT     326074.0
VA     778870.0
VT     240202.0
WA     359583.0
WI     487166.0
WV      30510.0
WY     112500.0
Name: AwardTotal, dtype: float64
2001
InstState
AK     486990.0
AL     622343.0
AR      86139.0
AZ    1053971.0
CA    1788585.0
CO    1334514.0
CT     159185.0
DC     589887.0
DE     158356.0
FL     794185.0
GA     207168.0
HI     784004.0
IA     333124.0
ID      42053.0
IL    2301983.0
IN     331298.0
KS     239047.0
KY    1093576.0
LA     196647.0
MA    2594900.0
MD     955041.0
ME     593854.0
MI    1189322.0
MN     640612.0
MO     940040.0
MS     220907.0
MT     506610.0
NC     891083.0
ND      31830.0
NE     420308.0
NH     237894.0
NJ     270794.0
NM     506800.0
NV     217485.0
NY    4229819.0
OH     751882.0
OK     794600.0
OR     194432.0
PA    1778846.0
RI       6370.0
SC     127015.0
SD     147555.0
TN     592567.0
TX    1541045.0
UT      68970.0
VA     691782.0
VT     385223.0
WA    1355816.0
WI     840714.0
WV       4745.0
WY      22679.0
Name: AwardTotal, dtype: float64
2002
InstState
AK     940573.0
AL     181015.0
AR     137742.0
AZ     431628.0
CA    4316963.0
CO     778252.0
CT     764679.0
DC     828577.0
DE     208594.0
FL    1920181.0
GA     123615.0
HI     477985.0
IA     508376.0
ID      35579.0
IL    3368439.0
IN     197478.0
KS     518931.0
KY     324512.0
LA     831013.0
MA    1419298.0
MD    1094771.0
ME    1557715.0
MI    1639435.0
MN     683821.0
MO     302206.0
MS     118870.0
MT     550587.0
NC     963998.0
ND     104397.0
NE     543419.0
NH     317183.0
NJ     246921.0
NM     881882.0
NV      54900.0
NY    4244706.0
OH     893431.0
OK     272299.0
OR     544313.0
PA    1114208.0
RI     241760.0
SC     304520.0
SD     437234.0
TN     434147.0
TX     904933.0
UT     317891.0
VA    1316152.0
VT     163320.0
WA     584244.0
WI     745393.0
WV      35034.0
WY      22610.0
Name: AwardTotal, dtype: float64
2003
InstState
AK     715177.0
AL     481052.0
AR      60219.0
AZ    1038521.0
CA    2679706.0
CO     978216.0
CT     701240.0
DC    1193537.0
DE      77935.0
FL    2114745.0
GA     157359.0
HI     538076.0
IA     656233.0
ID      92209.0
IL    5093762.0
IN     179496.0
KS      51212.0
KY     253836.0
LA     377679.0
MA    3452401.0
MD    1098073.0
ME     895029.0
MI    1120055.0
MN     938471.0
MO     501114.0
MS     472587.0
MT     381033.0
NC    1732331.0
ND     108337.0
NE     256586.0
NH     413496.0
NJ    1516792.0
NM     668767.0
NV     549745.0
NY    4997931.0
OH    1360551.0
OK     263412.0
OR     751967.0
PA    3298410.0
RI      23459.0
SC     826880.0
SD      18295.0
TN     663892.0
TX    2798686.0
UT     625093.0
VA     748363.0
VT     123309.0
WA    1388010.0
WI    1059813.0
WV      74267.0
WY     236965.0
Name: AwardTotal, dtype: float64
2004
InstState
AK     530032.0
AL     629036.0
AR     144950.0
AZ     203588.0
CA    3525039.0
CO     958067.0
CT    1474991.0
DC    1395599.0
DE     156025.0
FL    1521274.0
GA     489795.0
HI     487837.0
IA     293800.0
ID      32855.0
IL    3380693.0
IN    2399292.0
KS     457141.0
KY     532784.0
LA     862580.0
MA    3848631.0
MD     352789.0
ME     575696.0
MI    1668467.0
MN    1018322.0
MO    1036214.0
MS      64548.0
MT     706867.0
NC    1711282.0
ND      77329.0
NE     497425.0
NH     288955.0
NJ    1499544.0
NM    1292570.0
NV      49040.0
NY    7556999.0
OH    2054731.0
OK     670719.0
OR     228650.0
PA    2547930.0
RI     184629.0
SC     116430.0
SD     205600.0
TN    1410097.0
TX    4737875.0
UT     404493.0
VA     655214.0
VT     156380.0
WA    1462241.0
WI    1066143.0
WV      32705.0
WY     299047.0
Name: AwardTotal, dtype: float64
2005
InstState
AK    1661978.0
AL      42585.0
AR      14035.0
AZ    2214015.0
CA    5277452.0
CO    1303005.0
CT     958939.0
DC     128260.0
DE      74145.0
FL    2195775.0
GA    1154912.0
HI    1223031.0
IA     123626.0
ID       2325.0
IL    6156005.0
IN    1892428.0
KS      26930.0
KY     174250.0
LA      28360.0
MA    3725472.0
MD    1484264.0
ME     531145.0
MI    2264762.0
MN     974440.0
MO     946118.0
MS      30176.0
MT     699459.0
NC    2563431.0
ND     165181.0
NE     585348.0
NH     185977.0
NJ     747226.0
NM     274483.0
NV     271197.0
NY    7821515.0
OH     992772.0
OK    1270426.0
OR     354156.0
PA    3879330.0
RI     531785.0
SC     228415.0
SD     242620.0
TN    2920500.0
TX    3208932.0
UT     367972.0
VA    1794048.0
VT     227053.0
WA    1180449.0
WI    1894573.0
WV     257196.0
WY      14035.0
Name: AwardTotal, dtype: float64
2006
InstState
AK     743125.0
AL     411295.0
AR      75237.0
AZ    2587775.0
CA    3761462.0
CO    2512645.0
CT     959690.0
DC    3285287.0
DE      74201.0
FL    1640913.0
GA     564577.0
HI     565185.0
IA    1302672.0
ID     120751.0
IL    4440174.0
IN     884197.0
KS    1107654.0
KY     137316.0
LA     705080.0
MA    3083367.0
MD     839446.0
ME     436323.0
MI    1972258.0
MN    1181188.0
MO    1753589.0
MS     104567.0
MT     866372.0
NC    2554228.0
ND      18000.0
NE     528551.0
NH      64364.0
NJ    1183689.0
NM     946888.0
NV     813378.0
NY    5788367.0
OH    1596396.0
OK     414768.0
OR      79900.0
PA    4971038.0
RI      30327.0
SC     978506.0
SD     242105.0
TN     729608.0
TX    1624557.0
UT     723270.0
VA    1521643.0
VT     571790.0
WA     710163.0
WI    1390048.0
WV     233529.0
WY     315679.0
Name: AwardTotal, dtype: float64
2007
InstState
AK    1475286.0
AL     154224.0
AR      18178.0
AZ    1346100.0
CA    5606165.0
CO    1806442.0
CT    1294736.0
DC    4334060.0
DE       8553.0
FL    1903580.0
GA    1737168.0
HI    1218914.0
IA    1354346.0
ID      82379.0
IL    8714815.0
IN    1690560.0
KS       6000.0
KY     168485.0
LA     360997.0
MA    2346070.0
MD     585667.0
ME    1258320.0
MI    2614113.0
MN     775543.0
MO    1757210.0
MS      58691.0
MT     602634.0
NC    1140060.0
ND     896655.0
NE     261224.0
NH     452838.0
NJ    2466336.0
NM     810311.0
NV     243546.0
NY    7286033.0
OH    1258325.0
OK    1165568.0
OR    1598203.0
PA    5133391.0
RI      56634.0
SC     256159.0
SD     334831.0
TN    1066956.0
TX    7635895.0
UT     579901.0
VA    1792080.0
VT     715519.0
WA    2008777.0
WI     374361.0
WY     176212.0
Name: AwardTotal, dtype: float64
2008
InstState
AK     907499.0
AL     194553.0
AZ    1888830.0
CA    6463196.0
CO    2104221.0
CT    1168571.0
DC    1040815.0
DE     303373.0
FL    3006463.0
GA     280210.0
HI     875832.0
IA     489967.0
IL    4025966.0
IN    1596911.0
KS     501739.0
KY     339420.0
LA     987207.0
MA    3856283.0
MD    2832791.0
ME     364238.0
MI    3444602.0
MN    1046508.0
MO     308719.0
MS     243765.0
MT     185603.0
NC    3561825.0
ND     150604.0
NE      61535.0
NH     568076.0
NJ     151700.0
NM     350081.0
NV     268731.5
NY    8149864.0
OH    1595558.0
OK     586350.0
OR     531970.0
PA    3185081.0
RI     369543.0
SC     263285.0
SD      96424.0
TN     957278.0
TX    7153598.0
UT     661325.0
VA    1845456.0
VT     565549.0
WA     643292.0
WI     275033.0
WY     356000.0
Name: AwardTotal, dtype: float64
2009
InstState
AK    1386152.0
AL     110227.0
AR      14013.0
AZ    1524376.0
CA    6549857.0
CO    3382778.0
CT    1214803.0
DC    5083706.0
FL    1163959.0
GA    1948415.0
HI    1932060.0
IA     294309.0
ID     143922.0
IL    2255902.0
IN     720013.0
KS     338677.0
KY    1240631.0
LA    1570076.0
MA    3825605.0
MD    1837368.0
ME     184809.0
MI    1202016.0
MN     541086.0
MO     930689.0
MS     630483.0
MT    1659968.0
NC    2971534.0
ND      51997.0
NE     348424.0
NH      58059.0
NJ     930308.0
NM     737105.0
NV     120933.0
NY    8677799.0
OH    1120422.0
OK    1536614.0
OR     361401.0
PA    2321637.0
RI     102450.0
SC     344078.0
SD     397519.0
TN    2712014.0
TX    2524379.0
UT    1538900.0
VA    1025054.0
VT     962266.0
WA    3188964.0
WI    1731807.0
WV       3000.0
WY     198943.0
Name: AwardTotal, dtype: float64
2010
InstState
AK    1060662.0
AL    1030046.0
AR     329016.0
AZ     920766.0
CA    7883435.0
CO    1098884.0
CT    1828060.0
DC    2328803.0
DE     536407.0
FL    1545250.0
GA     747318.0
HI    1849417.0
IA       2750.0
ID      39500.0
IL    7064397.0
IN     694491.0
KS       9000.0
KY     728818.0
LA     202129.0
MA    2154541.0
MD    1723227.0
ME    1819309.0
MI    4057716.0
MN     783588.0
MO     977240.0
MS     140143.0
MT     301629.0
NC    3280636.0
ND     137749.0
NE     936887.0
NH       5627.0
NJ     419191.0
NM    1062018.0
NV     173424.0
NY    9476440.0
OH    1528036.0
OK    1730534.0
OR     594831.0
PA    3507879.0
RI     652111.0
SC    2019425.0
SD      24000.0
TN    1685032.0
TX    2751334.0
UT     388242.0
VA     761112.0
VT     213847.0
WA    2258733.0
WI    1369880.0
WV      40000.0
WY      79973.0
Name: AwardTotal, dtype: float64
2011
InstState
AK    1076002.0
AL     321027.0
AZ    1399972.0
CA    4382686.0
CO     445961.0
CT    1090963.0
DC    5728761.0
DE     572725.0
FL     987181.0
GA     507549.0
HI     615699.0
IA     521531.0
ID     120053.0
IL    4681093.0
IN    2491909.0
KS     405446.0
KY    1466343.0
LA      78476.0
MA    2358998.0
MD    1877645.0
ME     153742.0
MI    2239460.0
MN    1312058.0
MO    1359115.0
MS      48525.0
MT     729103.0
NC    1787089.0
ND     537956.0
NE     163000.0
NH      86014.0
NJ     371153.0
NM     568227.0
NV     198411.0
NY    7410162.0
OH    1073571.0
OK     412587.0
OR    1794894.0
PA    2671396.0
RI     257874.0
SC     149734.0
SD      49750.0
TN    1272038.0
TX    2997634.0
UT     213708.0
VA    1335803.0
VT     261313.0
WA    2714101.0
WI     508279.0
WY     124847.0
Name: AwardTotal, dtype: float64
2012
InstState
AK    1509007.0
AL     464450.0
AR     245496.0
AZ     301594.0
CA    6925582.0
CO    2072922.0
CT     982889.0
DC    1664487.0
FL    2108613.0
GA     664995.0
HI     860629.0
IA     631699.0
ID     330975.0
IL    4952736.0
IN     340408.0
KS     198480.0
KY     250502.0
LA     490000.0
MA    2815506.0
MD    1411369.0
ME     198499.0
MI     530304.0
MN     862370.0
MO     992469.0
MS     362139.0
MT     742287.0
NC    1221514.0
ND     332014.0
NE     615171.0
NH      84784.0
NJ    1003535.0
NM     383008.0
NV     133994.0
NY    6377470.0
OH    1665429.0
OK    1532531.0
OR     801490.0
PA    3511191.0
RI     324914.0
SC     788350.0
SD      42000.0
TN    1275735.0
TX    2847145.0
UT     102300.0
VA     636882.0
VT     309097.0
WA    1266575.0
WI     897363.0
WY      14000.0
Name: AwardTotal, dtype: float64
2013
InstState
AK     864178.0
AL     190430.0
AR      31464.0
AZ     846379.0
CA    4281612.0
CO     696751.0
CT    1241251.0
DC    2627680.0
DE     557204.0
FL     557531.0
GA     149296.0
HI    1053104.0
IA      95040.0
ID      60793.0
IL    2639753.0
IN     549629.0
KS     787162.0
KY     145092.0
LA      47722.0
MA    2606501.0
MD    2482349.0
ME     766379.0
MI     776715.0
MN     954932.0
MO     667036.0
MT     123965.0
NC    1659021.0
NH     623601.0
NJ     142220.0
NM     437665.0
NV      96650.0
NY    7559582.0
OH    1820436.0
OK     461399.0
OR     448315.0
PA    1607818.0
RI     831025.0
SC    1064924.0
SD     203524.0
TN     978933.0
TX    3221081.0
UT      50000.0
VA    1201472.0
VT     211587.0
WA    2157270.0
WI    1335687.0
WY     149958.0
Name: AwardTotal, dtype: float64

In [29]:
scl = [[0.0, 'rgb(242,240,247)'],[0.2, 'rgb(218,218,235)'],[0.4, 'rgb(188,189,220)'],[0.6, 'rgb(158,154,200)'],[0.8, 'rgb(117,107,177)'],[1.0, 'rgb(84,39,143)']]

df5=df2.groupby('FiscalYear').get_group(1996)
df4=df5.groupby('InstState')
    #df5=df4.get_group
state=[]
amount=[]
for name,group in df4:
    state.append(str(name))
    amount.append(str(group['AwardTotal'].sum()))
#     state=df4['InstState'].unique()
#     state.append(df4.groups)
location = pd.DataFrame(state,columns = ['state'])
total= pd.DataFrame(amount,columns = ['amount'])
#     yearly.append(total)
# for i in range(3):
data = [ dict(
            type='choropleth',
            colorscale = scl,
#             autocolorscale = False,
#         locations=df['InstState'].unique(),

#             locations=state[i],
#             z = yearly[i],
            locations = location['state'],
            z = total['amount'],
#             df4['text'] = 'State: ' + df4.groups+ '<br>Total Amount: '+ z + ' dollar',
            text = 'State: ' + location['state'] + '<br>Total Amount: '+ total['amount'] + ' dollar',
            locationmode = 'USA-states',
            marker = dict(
                line = dict (
                    color = 'rgb(255,255,255)',
                    width = 2
                ) ),
            colorbar = dict(
                title = "Millions USD")
            ) ]
layout = dict(
            #title = str(1996+i)+'US Administrative Discretionary Grants<br>(Hover for breakdown)',
            title = '1996 US Administrative Discretionary Grants<br>(Hover for breakdown)',
            geo = dict(
                scope='usa',
                projection=dict( type='albers usa' ),
                showlakes = True,
                lakecolor = 'rgb(255, 255, 255)'),
                 )
fig = dict( data=data, layout=layout )
py.plotly.iplot( fig)
#break
    #py.iplot(fig)


Out[29]:

In [30]:
scl = [[0.0, 'rgb(242,240,247)'],[0.2, 'rgb(218,218,235)'],[0.4, 'rgb(188,189,220)'],[0.6, 'rgb(158,154,200)'],[0.8, 'rgb(117,107,177)'],[1.0, 'rgb(84,39,143)']]

df5=df2.groupby('FiscalYear').get_group(2013)
df4=df5.groupby('InstState')
    #df5=df4.get_group
state=[]
amount=[]
for name,group in df4:
    state.append(str(name))
    amount.append(str(group['AwardTotal'].sum()))
#     state=df4['InstState'].unique()
#     state.append(df4.groups)
location = pd.DataFrame(state,columns = ['state'])
total= pd.DataFrame(amount,columns = ['amount'])
#     yearly.append(total)
# for i in range(3):
data = [ dict(
            type='choropleth',
            colorscale = scl,
#             autocolorscale = False,
#         locations=df['InstState'].unique(),

#             locations=state[i],
#             z = yearly[i],
            locations = location['state'],
            z = total['amount'],
#             df4['text'] = 'State: ' + df4.groups+ '<br>Total Amount: '+ z + ' dollar',
            text = 'State: ' + location['state'] + '<br>Total Amount: '+ total['amount'] + ' dollar',
            locationmode = 'USA-states',
            marker = dict(
                line = dict (
                    color = 'rgb(255,255,255)',
                    width = 2
                ) ),
            colorbar = dict(
                title = "Millions USD")
            ) ]
layout = dict(
            #title = str(1996+i)+'US Administrative Discretionary Grants<br>(Hover for breakdown)',
            title = '2013 US Administrative Discretionary Grants<br>(Hover for breakdown)',
            geo = dict(
                scope='usa',
                projection=dict( type='albers usa' ),
                showlakes = True,
                lakecolor = 'rgb(255, 255, 255)'),
                 )
fig = dict( data=data, layout=layout )
py.plotly.iplot( fig)
#break
    #py.iplot(fig)


Out[30]:

Q2-2a We make heatmap on 1996 and 2013 total grant amount by 51 states and also the DC region. For the convenience of plotting, region with the abbreviation 'GU','PW','VI','MP','FM','MH''AS','PR' are omitted. The state with deeper color was entitled with larger amount. Here we find some variations on the amount and whether the state was granted. For instance, the maximum grants increased from 2 million up to 7 million. Another example is that California topped the granted amount in 1996 but was only amoung the middle in 2013. There are also states who wasn't granted during these seven years.


In [20]:
#Q2-2b BY XIAOLIANG JIANG
df2['Text'] = df2['Institution'] + '<br>' + df2['Program'] + '<br>' + 'Program Type: ' + df2['ProgramType'] + '<br>' + 'Total Award: ' + (df2['AwardTotal']/1e3).astype(str)+ ' thousand'
#df2['text'] = df2['Institution'] + 'Total Award' + (df2['AwardTotal']/1e3).astype(str)+ ' thousand'
limits = [(0,10),(10,100),(100,200),(200,500),(500,1000),(1000,3000)]
#colors = ["#ffcccc","#ffddcc","#ffeecc","#ffffcc","#eeffcc","#ddffcc"]
colors = ["e0e0e0","#66b2ff","#66ff66","#ffff66","#ffb266","#ff6666"]
institutions = []
scale = 6000

for i in range(len(limits)):
    subdf2=df2[((df2['AwardTotal']/1e3)<limits[i][1])&((df2['AwardTotal']/1e3)>limits[i][0])]
    institution = dict(
        type = 'scattergeo',
        locationmode = 'USA-states',
        lon = subdf2['Longitude'],
        lat = subdf2['Latitude'],
        text = subdf2['Text'],
        marker = dict(
            size = subdf2['AwardTotal']/scale,
            color = colors[i],
            line = dict(width=0.5, color='rgb(40,40,40)'),
            sizemode = 'area'
        ),
        name ='{0} - {1}'.format(limits[i][0],limits[i][1])+'  thousand dollar' )
    institutions.append(institution)

In [21]:
layout = dict(
        title = 'Administrative Discretionary Grants<br>(Click legend to toggle traces)',
        showlegend = True,
        geo = dict(
            scope='usa',
            projection=dict( type='albers usa' ),
            showland = True,
            landcolor = 'rgb(217, 217, 217)',
            subunitwidth=1,
            countrywidth=1,
            subunitcolor="rgb(255, 255, 255)",
            countrycolor="rgb(255, 255, 255)"
        ),
        updatemenus=list([
        dict(
            x=-0.05,
            y=1,
            yanchor='top',
            buttons=list([
                dict(
                    args=['visible', [True, True, True, True, True, True]],
                    label='All',
                    method='restyle'
                ),
                dict(
                    args=['visible', [True, False, False, False, False, False]],
                    label='0-10 thousand dollar',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, True, False, False, False, False]],
                    label='10-100 thousand dollar',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, True, False, False, False]],
                    label='100-200 thousand dollar',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, False, True, False, False]],
                    label='200-500 thousand dollar',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, False, False, True, False]],
                    label='500-1000 thousand dollar',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, False, False, False, True]],
                    label='1000+ thousand dollar',
                    method='restyle'
                )
            ]),
        )
    ]),
    )

fig = dict( data=institutions, layout=layout )
py.iplot( fig, validate=False, filename='q2testworldmap' )


Out[21]:

The map above is classified by project sized in different locations. There are 18 missing values and we add them mannually by looking for the address on the Google Map and record each instance's longitude and latitute. With the interactive map, you can view a single project amount class by double click on the color spot in front of the tag and hide the colorful spots by single click the spot before the item tag.

Summary: 0-10: large counts, nationwide, concentrated on east and west coasts 10-100: less counts, nationwide, concentrated on east and west coasts 100-200: less counts, nationwide, concentrated on east coast 200-500: less counts, nationwide, concentrated on east coast 500-1000: small countss, not so many in the middle, concentrated on east coast 1000-3000: only several counts, only at Chicago and NY and Boston.


In [38]:
df2['Text'] = df2['Institution'] + '<br>' + df2['Program'] + '<br>' + 'Program Type: ' + df2['ProgramType'] + '<br>' + 'Total Award: ' + (df2['AwardTotal']/1e3).astype(str)+ ' thousand'
#df2['text'] = df2['Institution'] + 'Total Award' + (df2['AwardTotal']/1e3).astype(str)+ ' thousand'
#limits = [(0,10),(10,100),(100,200),(200,500),(500,1000),(1000,3000)]
#colors = ["#ffcccc","#ffddcc","#ffeecc","#ffffcc","#eeffcc","#ddffcc"]
colors = ["#ff6666","#ffb266","#ffff66","#b2ff66","#66ff66","#66ffb2","#66ffff","#66b2ff","#6666ff","#ff66ff","#b266ff","#ff66b2","#000000","#404040","#808080","#c0c0c0","#ffffff"]
pt=["IL","ST","ML","RE","IC","IM","IS","MN","LE","MP","MH","LT","LI","IG","MA","IA","IG"]
institutions = []
scale = 5000

for i in range(len(colors)):
    subdf2=df2[df2["ProgramType"]==pt[16-i]]
    institution = dict(
        type = 'scattergeo',
        locationmode = 'USA-states',
        lon = subdf2['Longitude'],
        lat = subdf2['Latitude'],
        text = subdf2['Text'],
        marker = dict(
            size = subdf2['AwardTotal']/scale,
            color = colors[16-i],
            line = dict(width=0.5, color='rgb(40,40,40)'),
            sizemode = 'area'
        ),
        name =pt[i])
    institutions.append(institution)
layout = dict(
        title = 'Administrative Discretionary Grants<br>(Click legend to toggle traces)',
        showlegend = True,
        geo = dict(
            scope='usa',
            projection=dict( type='albers usa' ),
            showland = True,
            landcolor = 'rgb(217, 217, 217)',
            subunitwidth=1,
            countrywidth=1,
            subunitcolor="rgb(255, 255, 255)",
            countrycolor="rgb(255, 255, 255)"
        )
    )

fig = dict( data=institutions, layout=layout )
py.iplot( fig, validate=False, filename='q2testworldmap' )


Out[38]:

This interactive graph shows the geographic distribution of grant types in the United States. The size of spots on the map represents the amount of the grant. We can tell from the figure that certain grant types such as MN, IA and LE have less number of grants than others and are distibuted more evenly around the country. Grant types such as IG are mostly distributed along the east and west coast lines.

Summary:

IL, ML, RE: small amounts, large grant counts, nationwide but concentrated on northeastern. ST: smaller amounts, large counts, nationwide but concentrated on northeastern IC, IM: smaller amounts, small counts, nationwide but are less in mid and eastern, more concentrated on ALASKA IS,MA: small amounts, small counts, more concentrated on eastern MN,IA: large amounts, small counts, more concentrated along coast lines LE: small amounts, smaller counts, nationwide but less on eastern MP: smaller amounts, mid counts, nationwide but less on eastern NH,LI: smaller amounts, mid counts, nationwide but concentrated on eastern LT: smaller amounts, larger counte, nationwide IG: larger amounts, mid counts, nationwide, concentrated on eastern


In [36]:
#Q2-3 BY JIALU WANG
fn1 = "amt.csv"
with open(fn1, "r") as f:
    reader1 = csv.reader(f)
    header1 = next(reader1)
    data1 = {}
    for column1 in header1:
        data1[column1] = []
    for row1 in reader1:
        for column1, value1 in zip(header1, row1):
            data1[column1].append(value1)
            
fn2 = "GeoFRED_Total_Gross_Domestic_Product_by_State_Millions_of_Dollars.csv"
with open(fn2, "r") as f:
    reader2 = csv.reader(f)
    header2 = next(reader2)
    data2 = {}
    for column2 in header2:
        data2[column2] = []
    for row2 in reader2:
        for column2, value2 in zip(header2, row2):
            data2[column2].append(value2)

In [37]:
plt.rcParams["figure.figsize"] = (40, 20)
states =data2['InstState']
AWT1997=data1['1997']
GDP1997=data2['1997']
AWT1998=data1['1998']
GDP1998=data2['1998']
AWT1999=data1['1999']
GDP1999=data2['1999']
AWT2000=data1['2000']
GDP2000=data2['2000']
AWT2001=data1['2001']
GDP2001=data2['2001']
AWT2002=data1['2002']
GDP2002=data2['2002']
AWT2003=data1['2003']
GDP2003=data2['2003']
AWT2004=data1['2004']
GDP2004=data2['2004']
AWT2005=data1['2005']
GDP2005=data2['2005']
AWT2006=data1['2006']
GDP2006=data2['2006']
AWT2007=data1['2007']
GDP2007=data2['2007']
AWT2008=data1['2008']
GDP2008=data2['2008']
AWT2009=data1['2009']
GDP2009=data2['2009']
AWT2010=data1['2010']
GDP2010=data2['2010']
AWT2011=data1['2011']
GDP2011=data2['2011']
AWT2012=data1['2012']
GDP2012=data2['2012']
AWT2013=data1['2013']
GDP2013=data2['2013']


trace11 = go.Scatter(
    x = states,
    y = AWT1997,
    mode = 'lines+markers',
    name = 'Awarded Amount'
)
trace12 = go.Scatter(
    x = states,
    y = GDP1997,
    mode = 'lines+markers',
    name = 'GDP'
)
trace21 = go.Scatter(
    x = states,
    y = AWT1998,
    mode = 'lines+markers',
    name = 'Awarded Amount'
)
trace22 = go.Scatter(
    x = states,
    y = GDP1998,
    mode = 'lines+markers',
    name = 'GDP'
)
trace31 = go.Scatter(
    x = states,
    y = AWT1999,
    mode = 'lines+markers',
    name = 'Awarded Amount'
)
trace32 = go.Scatter(
    x = states,
    y = GDP1999,
    mode = 'lines+markers',
    name = 'GDP'
)
trace41 = go.Scatter(
    x = states,
    y = AWT2000,
    mode = 'lines+markers',
    name = 'Awarded Amount'
)
trace42 = go.Scatter(
    x = states,
    y = GDP2000,
    mode = 'lines+markers',
    name = 'GDP'
)
trace51 = go.Scatter(
    x = states,
    y = AWT2001,
    mode = 'lines+markers',
    name = 'Awarded Amount'
)
trace52 = go.Scatter(
    x = states,
    y = GDP2001,
    mode = 'lines+markers',
    name = 'GDP'
)
trace61 = go.Scatter(
    x = states,
    y = AWT2002,
    mode = 'lines+markers',
    name = 'Awarded Amount'
)
trace62 = go.Scatter(
    x = states,
    y = GDP2002,
    mode = 'lines+markers',
    name = 'GDP'
)
trace71 = go.Scatter(
    x = states,
    y = AWT2003,
    mode = 'lines+markers',
    name = 'Awarded Amount'
)
trace72 = go.Scatter(
    x = states,
    y = GDP2003,
    mode = 'lines+markers',
    name = 'GDP'
)
trace81 = go.Scatter(
    x = states,
    y = AWT2004,
    mode = 'lines+markers',
    name = 'Awarded Amount'
)
trace82 = go.Scatter(
    x = states,
    y = GDP2004,
    mode = 'lines+markers',
    name = 'GDP'
)
trace91 = go.Scatter(
    x = states,
    y = AWT2005,
    mode = 'lines+markers',
    name = 'Awarded Amount'
)
trace92 = go.Scatter(
    x = states,
    y = GDP2005,
    mode = 'lines+markers',
    name = 'GDP'
)
trace101 = go.Scatter(
    x = states,
    y = AWT2006,
    mode = 'lines+markers',
    name = 'Awarded Amount'
)
trace102 = go.Scatter(
    x = states,
    y = GDP2006,
    mode = 'lines+markers',
    name = 'GDP'
)
trace111 = go.Scatter(
    x = states,
    y = AWT2007,
    mode = 'lines+markers',
    name = 'Awarded Amount'
)
trace112 = go.Scatter(
    x = states,
    y = GDP2007,
    mode = 'lines+markers',
    name = 'GDP'
)
trace121 = go.Scatter(
    x = states,
    y = AWT2008,
    mode = 'lines+markers',
    name = 'Awarded Amount'
)
trace122 = go.Scatter(
    x = states,
    y = GDP2008,
    mode = 'lines+markers',
    name = 'GDP'
)
trace131 = go.Scatter(
    x = states,
    y = AWT2009,
    mode = 'lines+markers',
    name = 'Awarded Amount'
)
trace132 = go.Scatter(
    x = states,
    y = GDP2009,
    mode = 'lines+markers',
    name = 'GDP'
)
trace141 = go.Scatter(
    x = states,
    y = AWT2010,
    mode = 'lines+markers',
    name = 'Awarded Amount'
)
trace142 = go.Scatter(
    x = states,
    y = GDP2010,
    mode = 'lines+markers',
    name = 'GDP'
)
trace151 = go.Scatter(
    x = states,
    y = AWT2011,
    mode = 'lines+markers',
    name = 'Awarded Amount'
)
trace152 = go.Scatter(
    x = states,
    y = GDP2011,
    mode = 'lines+markers',
    name = 'GDP'
)
trace161 = go.Scatter(
    x = states,
    y = AWT2012,
    mode = 'lines+markers',
    name = 'Awarded Amount'
)
trace162 = go.Scatter(
    x = states,
    y = GDP2012,
    mode = 'lines+markers',
    name = 'GDP'
)
trace171 = go.Scatter(
    x = states,
    y = AWT2013,
    mode = 'lines+markers',
    name = 'Awarded Amount'
)
trace172 = go.Scatter(
    x = states,
    y = GDP2013,
    mode = 'lines+markers',
    name = 'GDP'
)

mydata = [trace11,trace12,trace21,trace22,trace31,trace32,trace41,trace42,
         trace51,trace52,trace61,trace62,trace71,trace72,trace81,trace82,
         trace91,trace92,trace101,trace102,trace111,trace112,trace121,trace122,
         trace131,trace132,trace141,trace142,trace151,trace152,trace161,trace162,
         trace171,trace172]
layout = Layout(
    title='Total State Amount vs GDP by State Per Year',
    updatemenus=list([
        dict(
            x=-0.05,
            y=1,
            yanchor='top',
            buttons=list([
                dict(
                    args=['visible', [True,True, False, False,False, False, False, False,
                                      False, False, False, False,False, False, False, False,
                                     False, False, False, False,False, False, False, False,
                                     False, False, False, False,False, False, False, False,
                                     False, False]],
                    label='1997',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, True,True,False, False, False, False,
                                      False, False, False, False,False, False, False, False,
                                     False, False, False, False,False, False, False, False,
                                     False, False, False, False,False, False, False, False,
                                     False, False]],
                    label='1998',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, False, False, True,True,False, False,
                                      False, False, False, False,False, False, False, False,
                                     False, False, False, False,False, False, False, False,
                                     False, False, False, False,False, False, False, False,
                                     False, False]],
                    label='1999',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, False, False, False, False,True,True,
                                      False, False, False, False,False, False, False, False,
                                     False, False, False, False,False, False, False, False,
                                     False, False, False, False,False, False, False, False,
                                     False, False]],
                    label='2000',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, False, False, False, False,False, False, 
                                      True,True,False, False,False, False, False, False,
                                     False, False, False, False,False, False, False, False,
                                     False, False, False, False,False, False, False, False,
                                     False, False]],
                    label='2001',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, False, False, False, False,False, False, 
                                      False, False,True,True,False, False, False, False,
                                     False, False, False, False,False, False, False, False,
                                     False, False, False, False,False, False, False, False,
                                     False, False]],
                    label='2002',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, False, False, False, False,False, False, 
                                      False, False,False, False, True,True,False, False,
                                     False, False, False, False,False, False, False, False,
                                     False, False, False, False,False, False, False, False,
                                     False, False]],
                    label='2003',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, False, False, False, False,False, False, 
                                      False, False,False, False, False, False,True,True,
                                     False, False, False, False,False, False, False, False,
                                     False, False, False, False,False, False, False, False,
                                     False, False]],
                    label='2004',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, False, False, False, False,False, False, 
                                      False, False,False, False, False, False,False, False, 
                                      True,True,False, False,False, False, False, False,
                                     False, False, False, False,False, False, False, False,
                                     False, False]],
                    label='2005',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, False, False, False, False,False, False, 
                                      False, False,False, False, False, False,False, False, 
                                      False, False,True,True,False, False, False, False,
                                     False, False, False, False,False, False, False, False,
                                     False, False]],
                    label='2006',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, False, False, False, False,False, False, 
                                      False, False,False, False, False, False,False, False, 
                                      False, False,False, False, True,True,False, False,
                                     False, False, False, False,False, False, False, False,
                                     False, False]],
                    label='2007',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, False, False, False, False,False, False, 
                                      False, False,False, False, False, False,False, False, 
                                      False, False,False, False, False, False,True,True,
                                     False, False, False, False,False, False, False, False,
                                     False, False]],
                    label='2008',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, False, False, False, False,False, False, 
                                      False, False,False, False, False, False,False, False, 
                                      False, False,False, False, False, False,False, False, 
                                      True,True,False, False,False, False, False, False,
                                     False, False]],
                    label='2009',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, False, False, False, False,False, False, 
                                      False, False,False, False, False, False,False, False, 
                                      False, False,False, False, False, False,False, False, 
                                      False, False,True,True,False, False, False, False,
                                     False, False]],
                    label='2010',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, False, False, False, False,False, False, 
                                      False, False,False, False, False, False,False, False, 
                                      False, False,False, False, False, False,False, False, 
                                      False, False,False, False, True,True,False, False,
                                     False, False]],
                    label='2011',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, False, False, False, False,False, False, 
                                      False, False,False, False, False, False,False, False, 
                                      False, False,False, False, False, False,False, False, 
                                      False, False,False, False, False, False,True,True,
                                     False, False]],
                    label='2012',
                    method='restyle'
                ),
                dict(
                    args=['visible', [False, False, False, False, False, False,False, False, 
                                      False, False,False, False, False, False,False, False, 
                                      False, False,False, False, False, False,False, False, 
                                      False, False,False, False, False, False,False, False,
                                      True,True]],
                    label='2013',
                    method='restyle'
                ),
                
            ]),
        )
    ]),
)
fig = Figure(data=mydata, layout=layout)
py.iplot(fig)


Out[37]:

Q2-3 The graph is a comparison between total awarded amount by state and GDP by state, as an indicator for the economic environment.The dropdown menu is the year of the statistics. From each year's line chart, we can see that states with higher GDP generally has higher amount of grants. For instance, CA, FL, PA, TX, NM has higher GDP compared to other states and they are also entitled with higher grant amount. However, there are also some states such as IL and NY with low GDP but high grant amount. We guess that there might be special study programs promoted by the government to support local library and museum development.It can also be observed that with the steady increasement of GDP year by year, the grant amount also sees a general increasing trend.