In [53]:
import pandas as pd
import numpy as np
import json
import geopy
import time
import math 
import logging
import matplotlib.pyplot as plt
from scipy.stats import ttest_ind

In [8]:
p3_cantons_data = pd.read_pickle('P3_Cantons.pickle')
p3_cantons_data


Out[8]:
Funding Instrument Funding Instrument Hierarchy Institution University Start Date End Date Approved Amount Canton Longname Canton Shortname
0 Project funding (Div. I-III) Project funding NaN Nicht zuteilbar - NA 01.10.1975 30.09.1976 11619.00 N/A N/A
1 Project funding (Div. I-III) Project funding Faculté de Psychologie et des Sciences de l'Ed... Université de Genève - GE 01.10.1975 30.09.1976 41022.00 Genève GE
2 Project funding (Div. I-III) Project funding Kommission für das Corpus philosophorum medii ... NPO (Biblioth., Museen, Verwalt.) - NPO 01.03.1976 28.02.1985 79732.00 Zurich ZH
3 Project funding (Div. I-III) Project funding Abt. Handschriften und Alte Drucke Bibliothek ... Universität Basel - BS 01.10.1975 30.09.1976 52627.00 Basel-Stadt BS
4 Project funding (Div. I-III) Project funding Schweiz. Thesauruskommission NPO (Biblioth., Museen, Verwalt.) - NPO 01.01.1976 30.04.1978 120042.00 Zurich ZH
5 Project funding (Div. I-III) Project funding Séminaire de politique économique, d'économie ... Université de Fribourg - FR 01.01.1976 31.12.1978 53009.00 Fribourg FR
6 Project funding (Div. I-III) Project funding Institut für ökumenische Studien Université de... Université de Fribourg - FR 01.01.1976 31.12.1976 25403.00 Fribourg FR
7 Project funding (Div. I-III) Project funding Ostasiatisches Seminar Universität Zürich Universität Zürich - ZH 01.10.1975 31.03.1977 47100.00 Zürich ZH
8 Project funding (Div. I-III) Project funding NaN Université de Lausanne - LA 01.10.1975 31.03.1977 25814.00 Vaud VD
9 Project funding (Div. I-III) Project funding Laboratoire de Didactique et Epistémologie des... Université de Genève - GE 01.10.1975 30.09.1978 360000.00 Genève GE
10 Project funding (Div. I-III) Project funding Klinische Psychologie und Psychotherapie Insti... Université de Fribourg - FR 01.10.1975 31.12.1978 153886.00 Fribourg FR
11 Project funding (Div. I-III) Project funding Schweizerische Rechtsquellen c/o Universität Z... NPO (Biblioth., Museen, Verwalt.) - NPO 01.10.1975 30.09.1978 862200.00 Zurich ZH
12 Project funding (Div. I-III) Project funding Département de Sociologie Faculté des Sciences... Université de Genève - GE 01.10.1975 30.09.1977 116991.00 Genève GE
13 Project funding (Div. I-III) Project funding Institut für Volkswirtschaft WWZ / FGS Univers... Universität Basel - BS 01.10.1975 31.12.1978 112664.00 Basel-Stadt BS
14 Project funding (Div. I-III) Project funding Soziologisches Institut Universität Zürich Universität Zürich - ZH 01.10.1975 31.12.1975 5000.00 Zürich ZH
15 Project funding (Div. I-III) Project funding Forschungszentrum FAL Université de Fribourg - FR 01.10.1975 30.09.1977 204018.00 Fribourg FR
16 Project funding (Div. I-III) Project funding Faculté de Psychologie et des Sciences de l'Ed... Université de Genève - GE 01.10.1975 30.09.1977 149485.00 Genève GE
17 Project funding (Div. I-III) Project funding Soziologisches Institut Universität Zürich Universität Zürich - ZH 01.01.1976 31.08.1977 83983.00 Zürich ZH
18 Project funding (Div. I-III) Project funding NaN Nicht zuteilbar - NA 01.01.1976 31.12.1976 38152.00 N/A N/A
19 Project funding (Div. I-III) Project funding NaN Université de Lausanne - LA 01.12.1975 31.01.1977 14138.00 Vaud VD
20 Project funding (Div. I-III) Project funding Faculté de Psychologie et des Sciences de l'Ed... Université de Genève - GE 01.10.1975 30.09.1978 164602.00 Genève GE
21 Project funding (Div. I-III) Project funding NaN Universität Bern - BE 01.10.1975 30.04.1978 147795.00 Canton of Bern BE
22 Project funding (Div. I-III) Project funding Forschungsbereich Politisches Verhalten und Oe... Universität Zürich - ZH 01.01.1976 30.06.1977 24552.00 Zürich ZH
23 Project funding (Div. I-III) Project funding Département des langues et des littératures fr... Université de Genève - GE 01.10.1975 30.09.1978 44802.00 Genève GE
24 Project funding (Div. I-III) Project funding NaN Nicht zuteilbar - NA 01.01.1976 31.12.1979 56000.00 N/A N/A
25 Project funding (Div. I-III) Project funding NaN Nicht zuteilbar - NA 01.10.1975 30.09.1977 152535.00 N/A N/A
26 Project funding (Div. I-III) Project funding Schweizerische Gesellschaft für Volkskunde NPO (Biblioth., Museen, Verwalt.) - NPO 01.10.1975 30.09.1976 225000.00 Zurich ZH
27 Project funding (Div. I-III) Project funding Kuratorium Carl J. Burckhardt NPO (Biblioth., Museen, Verwalt.) - NPO 01.10.1975 30.04.1978 179124.00 Zurich ZH
28 Project funding (Div. I-III) Project funding NaN Universität Zürich - ZH 01.10.1975 31.03.1976 20000.00 Zürich ZH
29 Project funding (Div. I-III) Project funding Eidg. Forschungsanstalt für Wald, Schnee und L... Eidg. Forschungsanstalt für Wald,Schnee,Land -... 01.10.1975 30.09.1978 445198.00 Vaud VD
... ... ... ... ... ... ... ... ... ...
53029 Publication grants Science communication Institut Sozialmanagement und Sozialpolitik Ho... Hochschule Luzern - HSLU 01.08.2016 31.07.2017 1898.00 Lucerne LU
53030 International short research visits Careers Stiftung Bibliothek Werner Oechslin NaN 01.07.2016 30.09.2016 9300.00 N/A N/A
53031 International short research visits Careers School of Geographical Sciences University of ... NaN 01.08.2016 31.10.2016 9500.00 N/A N/A
53032 International short research visits Careers NaN NaN 01.07.2016 31.07.2016 4000.00 N/A N/A
53033 International short research visits Careers CSIRO Marine and Atmospheric Research NaN 01.08.2016 31.10.2016 11000.00 N/A N/A
53034 International short research visits Careers NaN NaN 01.07.2016 31.08.2016 7500.00 N/A N/A
53035 International short research visits Careers Departement Geographie, SIE Universität Zürich NaN 01.08.2016 30.09.2016 8000.00 N/A N/A
53036 International short research visits Careers CReAM Department of Economics University Colle... NaN 01.09.2016 30.11.2016 9300.00 N/A N/A
53037 International short research visits Careers NaN NaN 01.08.2016 30.09.2016 7000.00 N/A N/A
53038 International short research visits Careers Eawag NaN 01.09.2016 31.10.2016 6000.00 N/A N/A
53039 International short research visits Careers Catholic University of Bukavu NaN 01.09.2016 30.09.2016 4500.00 N/A N/A
53040 Scientific Conferences Science communication Fondation Jean Monnet pour l'Europe Centre de ... NPO (Biblioth., Museen, Verwalt.) - NPO 01.10.2016 31.12.2016 2800.00 Zurich ZH
53041 NRP 68 Sustainable Use of Soil as a Resource Programmes;National Research Programmes (NRPs) Planning of Landscape and Urban Systems Instit... ETH Zürich - ETHZ 01.10.2016 30.09.2017 99952.00 Zurich ZH
53042 NRP 68 Sustainable Use of Soil as a Resource Programmes;National Research Programmes (NRPs) Forschungsanstalt Agroscope Reckenholz-Tänikon... Forschungsanstalten Agroscope - AGS 01.10.2016 31.12.2017 98040.00 Canton of Bern BE
53043 NRP 68 Sustainable Use of Soil as a Resource Programmes;National Research Programmes (NRPs) Forschung und Beratung in Wirtschaft und Polit... Firmen/Privatwirtschaft - FP 01.09.2016 28.02.2018 100000.00 Aargau AG
53044 International short research visits Careers Zoologisches Institut Universität Basel NaN 01.09.2016 30.11.2016 10500.00 N/A N/A
53045 International Exploratory Workshops Science communication Zentrum für Religion, Wirtschaft und Politik T... Universität Basel - BS 01.10.2016 31.12.2016 10030.00 Basel-Stadt BS
53046 International short research visits Careers Abteilung für Neuropsychologie Zentrum für Kog... NaN 01.08.2016 31.10.2016 7870.00 N/A N/A
53047 International short research visits Careers NaN NaN 01.08.2016 31.08.2016 3150.00 N/A N/A
53048 Scientific Conferences Science communication Abteilung für Indologie Universität Zürich Universität Zürich - ZH 01.10.2016 31.12.2016 10600.00 Zürich ZH
53049 Scientific Conferences Science communication Institut Religions, Cultures, Modernité FTSR U... Université de Lausanne - LA 01.10.2016 31.12.2016 2515.00 Vaud VD
53050 International short research visits Careers NaN NaN 01.10.2016 31.10.2016 3500.00 N/A N/A
53051 International short research visits Careers Department of Physics University of Massachusetts NaN 01.10.2016 31.10.2016 4000.00 N/A N/A
53052 International short research visits Careers NaN NaN 01.09.2016 30.09.2016 3550.00 N/A N/A
53053 Scientific Conferences Science communication Haute École d'art et de design - Genève HES-SO HES de Suisse occidentale - HES-SO 01.10.2016 31.12.2016 3000.00 Canton of Solothurn SO
53054 Scientific Conferences Science communication Departement Design Zürcher Hochschule der Küns... Zürcher Fachhochschule (ohne PH) - ZFH 01.10.2016 31.12.2016 1000.00 Zurich ZH
53055 Scientific Conferences Science communication Institute Performing Arts and Film Zürcher Hoc... Zürcher Fachhochschule (ohne PH) - ZFH 01.09.2016 30.11.2016 2000.00 Zurich ZH
53056 International short research visits Careers Department of Electrical Engineering and Compu... NaN 01.09.2016 31.12.2016 10500.00 N/A N/A
53057 International short research visits Careers Département de Biologie Faculté des Sciences U... NaN 01.09.2016 30.11.2016 9500.00 N/A N/A
53058 International short research visits Careers The Forsyth Institute Department of Microbiolo... NaN 01.10.2016 30.11.2016 7000.00 N/A N/A

53059 rows × 9 columns


In [9]:
#delete irrelevant columns in the dataset to clean data
p3_cantons_data = p3_cantons_data.drop(['Funding Instrument', 'Canton Longname', 'End Date', 'Start Date', 'Institution', 'University', 'Funding Instrument Hierarchy'], axis=1)
p3_cantons_data


Out[9]:
Approved Amount Canton Shortname
0 11619.00 N/A
1 41022.00 GE
2 79732.00 ZH
3 52627.00 BS
4 120042.00 ZH
5 53009.00 FR
6 25403.00 FR
7 47100.00 ZH
8 25814.00 VD
9 360000.00 GE
10 153886.00 FR
11 862200.00 ZH
12 116991.00 GE
13 112664.00 BS
14 5000.00 ZH
15 204018.00 FR
16 149485.00 GE
17 83983.00 ZH
18 38152.00 N/A
19 14138.00 VD
20 164602.00 GE
21 147795.00 BE
22 24552.00 ZH
23 44802.00 GE
24 56000.00 N/A
25 152535.00 N/A
26 225000.00 ZH
27 179124.00 ZH
28 20000.00 ZH
29 445198.00 VD
... ... ...
53029 1898.00 LU
53030 9300.00 N/A
53031 9500.00 N/A
53032 4000.00 N/A
53033 11000.00 N/A
53034 7500.00 N/A
53035 8000.00 N/A
53036 9300.00 N/A
53037 7000.00 N/A
53038 6000.00 N/A
53039 4500.00 N/A
53040 2800.00 ZH
53041 99952.00 ZH
53042 98040.00 BE
53043 100000.00 AG
53044 10500.00 N/A
53045 10030.00 BS
53046 7870.00 N/A
53047 3150.00 N/A
53048 10600.00 ZH
53049 2515.00 VD
53050 3500.00 N/A
53051 4000.00 N/A
53052 3550.00 N/A
53053 3000.00 SO
53054 1000.00 ZH
53055 2000.00 ZH
53056 10500.00 N/A
53057 9500.00 N/A
53058 7000.00 N/A

53059 rows × 2 columns


In [36]:
# define which cantons are german speaking and which are french speaking
# assumption: of the mixed language cantons, only Valais is categorized as French, others are German
german = ['AG','AR','AI', 'ZH', 'BE', 'LU', 'UR', 'SZ', 'OW', 'NW', 'GL', 'ZG', 'FR', 'SO', 'BS', 'SH', 'SG', 'GR', 'TG']
french = ['VD', 'NE', 'GE', 'JU', 'VS']
#delete N/As and Italian Cantons
p3_cantons_data = p3_cantons_data[p3_cantons_data['Canton Shortname'] != 'N/A']
p3_cantons_data = p3_cantons_data[p3_cantons_data['Canton Shortname'] != 'TI']


#add language code for german and french
p3_cantons_data["Language"] = ""
p3_cantons_data['Language'] = ['GE' if x in german else 'FR'for x in p3_cantons_data['Canton Shortname']]



p3_cantons_data


Out[36]:
Approved Amount Canton Shortname Language
1 41022.00 GE FR
2 79732.00 ZH GE
3 52627.00 BS GE
4 120042.00 ZH GE
5 53009.00 FR GE
6 25403.00 FR GE
7 47100.00 ZH GE
8 25814.00 VD FR
9 360000.00 GE FR
10 153886.00 FR GE
11 862200.00 ZH GE
12 116991.00 GE FR
13 112664.00 BS GE
14 5000.00 ZH GE
15 204018.00 FR GE
16 149485.00 GE FR
17 83983.00 ZH GE
19 14138.00 VD FR
20 164602.00 GE FR
21 147795.00 BE GE
22 24552.00 ZH GE
23 44802.00 GE FR
26 225000.00 ZH GE
27 179124.00 ZH GE
28 20000.00 ZH GE
29 445198.00 VD FR
30 85938.00 ZH GE
31 8902.00 ZH GE
32 19134.00 BS GE
33 54509.00 ZH GE
... ... ... ...
52995 16000.00 ZH GE
52996 4600.00 GE FR
52997 251554.00 LU GE
52998 5700.00 GE FR
52999 10000.00 VD FR
53003 12416.00 ZH GE
53005 1600.00 BS GE
53006 3200.00 BS GE
53007 120000.00 ZH GE
53008 6300.00 ZH GE
53009 1500.00 ZH GE
53010 11782.00 VD FR
53011 2600.00 ZH GE
53012 7700.00 FR GE
53017 2500.00 FR GE
53018 5900.00 BE GE
53022 7500.00 BE GE
53024 3000.00 GE FR
53025 3600.00 VD FR
53029 1898.00 LU GE
53040 2800.00 ZH GE
53041 99952.00 ZH GE
53042 98040.00 BE GE
53043 100000.00 AG GE
53045 10030.00 BS GE
53048 10600.00 ZH GE
53049 2515.00 VD FR
53053 3000.00 SO GE
53054 1000.00 ZH GE
53055 2000.00 ZH GE

47701 rows × 3 columns


In [42]:
#convert values to ints
p3_cantons_data['Approved Amount'] = (p3_cantons_data['Approved Amount']).astype(float)

In [65]:
#find what distribution of grants looks like
p3_cantons_data['Approved Amount'].hist(bins=100)
pylab.show()



In [43]:
german_switz = p3_cantons_data[p3_cantons_data['Language']=='GE']
french_switz = p3_cantons_data[p3_cantons_data['Language']=='FR']

ttest_ind(german_switz['Approved Amount'], french_switz['Approved Amount'])


Out[43]:
Ttest_indResult(statistic=-6.0918357515998958, pvalue=1.1247462658557904e-09)

In [ ]:
# Result: with a p-value of nearly zero, there is a statistically significant difference between 
#how grants are distributed among german and french cantons
#HOWEVER, a t test is not an ideal way to test this because some basic assumptions of the distributions are not met
#such as a normal distribution