In [5]:
import numpy as np
import pandas as pd
In [6]:
np.random.seed(42)
names = ["Markus", "Marko", "Sascha", "Gloria", "Julian"]
np.random.shuffle(names)
names
Out[6]:
['Marko', 'Julian', 'Sascha', 'Markus', 'Gloria']
In [7]:
file = pd.read_csv("all_votes.tsv", sep='\t')
In [8]:
file.head()
Out[8]:
id poll_id mandate_label poll_label vote reason_no_show fraction_label poll_date
0 420205 4293 Frauke Petry (Bundestag 2017 - 2021) Änderung des Infektionsschutzgesetzes und Grun... no NaN fraktionslos (Bundestag 2017 - 2021) 2021-09-07
1 420204 4293 Frank Pasemann (Bundestag 2017 - 2021) Änderung des Infektionsschutzgesetzes und Grun... no NaN fraktionslos (Bundestag 2017 - 2021) 2021-09-07
2 420203 4293 Georg Nüßlein (Bundestag 2017 - 2021) Änderung des Infektionsschutzgesetzes und Grun... yes NaN fraktionslos (Bundestag 2017 - 2021) 2021-09-07
3 420202 4293 Mario Mieruch (Bundestag 2017 - 2021) Änderung des Infektionsschutzgesetzes und Grun... no NaN fraktionslos (Bundestag 2017 - 2021) 2021-09-07
4 420201 4293 Uwe Kamann (Bundestag 2017 - 2021) Änderung des Infektionsschutzgesetzes und Grun... no_show NaN fraktionslos (Bundestag 2017 - 2021) 2021-09-07

Which individual polititian missed most votes¶

In [9]:
set(file["vote"])
Out[9]:
{'abstain', 'no', 'no_show', 'yes'}
In [12]:
mandate = file.groupby(file["mandate_label"])
In [13]:
mandate.head()
Out[13]:
id poll_id mandate_label poll_label vote reason_no_show fraction_label poll_date
0 420205 4293 Frauke Petry (Bundestag 2017 - 2021) Änderung des Infektionsschutzgesetzes und Grun... no NaN fraktionslos (Bundestag 2017 - 2021) 2021-09-07
1 420204 4293 Frank Pasemann (Bundestag 2017 - 2021) Änderung des Infektionsschutzgesetzes und Grun... no NaN fraktionslos (Bundestag 2017 - 2021) 2021-09-07
2 420203 4293 Georg Nüßlein (Bundestag 2017 - 2021) Änderung des Infektionsschutzgesetzes und Grun... yes NaN fraktionslos (Bundestag 2017 - 2021) 2021-09-07
3 420202 4293 Mario Mieruch (Bundestag 2017 - 2021) Änderung des Infektionsschutzgesetzes und Grun... no NaN fraktionslos (Bundestag 2017 - 2021) 2021-09-07
4 420201 4293 Uwe Kamann (Bundestag 2017 - 2021) Änderung des Infektionsschutzgesetzes und Grun... no_show NaN fraktionslos (Bundestag 2017 - 2021) 2021-09-07
... ... ... ... ... ... ... ... ...
96139 280347 1572 Ralf Brauksiepe (Bundestag 2017 - 2021) Verlängerung des Anti-IS-Einsatzes der Bundesw... yes NaN CDU/CSU (Bundestag 2017 - 2021) 2018-10-18
96848 279638 1571 Ralf Brauksiepe (Bundestag 2017 - 2021) Anpassung des Kindergeldes für im Ausland lebe... no NaN CDU/CSU (Bundestag 2017 - 2021) 2018-10-18
97557 278931 1570 Ralf Brauksiepe (Bundestag 2017 - 2021) Änderungsantrag zur Brückenteilzeit no NaN CDU/CSU (Bundestag 2017 - 2021) 2018-10-18
98266 278224 1569 Ralf Brauksiepe (Bundestag 2017 - 2021) Überprüfung des Jahresmittelgrenzwerts für Sti... no_show NaN CDU/CSU (Bundestag 2017 - 2021) 2018-10-19
98975 277517 1568 Ralf Brauksiepe (Bundestag 2017 - 2021) Stärkung des Menschenrechts auf Religionsfreiheit no_show NaN CDU/CSU (Bundestag 2017 - 2021) 2018-10-19

3729 rows × 8 columns

In [21]:
file[[x == "no_show" for x in file["vote"]]].value_counts("mandate_label")
Out[21]:
mandate_label
Angela Merkel (Bundestag 2017 - 2021)        131
Ingrid Remmers (Bundestag 2017 - 2021)       120
Helge Braun (Bundestag 2017 - 2021)          110
Sahra Wagenknecht (Bundestag 2017 - 2021)    109
Marcus Held (Bundestag 2017 - 2021)          109
                                            ... 
Dietrich Monstadt (Bundestag 2017 - 2021)      1
Hermann Gröhe (Bundestag 2017 - 2021)          1
Markus Koob (Bundestag 2017 - 2021)            1
Fabian Jacobi (Bundestag 2017 - 2021)          1
Hansjörg Durz (Bundestag 2017 - 2021)          1
Name: count, Length: 716, dtype: int64
In [23]:
len(set(file["mandate_label"]))
Out[23]:
747
In [29]:
vote_counts = file.value_counts(["mandate_label","vote"])
#vote_counts[vote_counts["vote"] == "no_show"]
Out[29]:
mandate_label                                vote   
Angela Merkel (Bundestag 2017 - 2021)        no_show    131
Rainer Kraft (Bundestag 2017 - 2021)         no         124
Karsten Hilse (Bundestag 2017 - 2021)        no         122
Wolfgang Wiehle (Bundestag 2017 - 2021)      no         122
Michael Espendiller (Bundestag 2017 - 2021)  no         121
                                                       ... 
Karl-Heinz Brunner (Bundestag 2017 - 2021)   abstain      1
Georg Kippels (Bundestag 2017 - 2021)        no_show      1
Axel Müller (Bundestag 2017 - 2021)          abstain      1
Georg Nüßlein (Bundestag 2017 - 2021)        abstain      1
Daniela De Ridder (Bundestag 2017 - 2021)    abstain      1
Name: count, Length: 2628, dtype: int64

How similar was the voting pattern of each party?¶

In [31]:
set(file["fraction_label"])
Out[31]:
{'AfD (Bundestag 2017 - 2021)',
 'CDU/CSU (Bundestag 2017 - 2021)',
 'DIE GRÜNEN (Bundestag 2017 - 2021)',
 'DIE LINKE (Bundestag 2017 - 2021)',
 'FDP (Bundestag 2017 - 2021)',
 'SPD (Bundestag 2017 - 2021)',
 'fraktionslos (Bundestag 2017 - 2021)'}
In [39]:
afd_votes = file[file["fraction_label"]=='AfD (Bundestag 2017 - 2021)']
In [45]:
afd_votes_4293 = afd_votes[afd_votes["poll_id"]== 4293]
afd_votes_4293.head()
afd_votes_4293.value_counts(["vote"])
Out[45]:
vote   
no         79
no_show     7
Name: count, dtype: int64
In [49]:
afd_votes.value_counts(["poll_id","vote"],sort=False)
Out[49]:
poll_id  vote   
1237     no         90
         no_show     2
1238     no          2
         no_show     3
         yes        87
                    ..
4283     yes        26
4284     no         68
         no_show    18
4293     no         79
         no_show     7
Name: count, Length: 435, dtype: int64
In [52]:
np.random.seed()
names = ["Markus", "Marko", "Sascha", "Gloria", "Julian"]
np.random.shuffle(names)
names
Out[52]:
['Julian', 'Gloria', 'Marko', 'Markus', 'Sascha']