Exploratory Analysis - Maharashtra State Elections-2014

Pratap Vardhan


In [1]:
import pandas as pd
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [2]:
"""
Results scraped from ECI site.
Code for the same can be found in the parent repo.
"""
df = pd.read_csv("eci-2014-states-candidate-wise.csv")

In [3]:
df = df[df['State-code']=='S13']

In [4]:
df.head(2)


Out[4]:
Candidate Party Votes State Constituency State-code Constituency-code
1441 PADAVI ADV. K.C. Indian National Congress 64410 Maharashtra Akkalkuwa S13 1
1442 PARADAKE VIJAYSING RUPSING Nationalist Congress Party 48635 Maharashtra Akkalkuwa S13 1

In [5]:
total_votes = df['Votes'].sum()
party_votes = df[['Votes', 'Party']].groupby('Party').sum().sort('Votes', ascending=False)
vote_shares = (100*party_votes/total_votes).reset_index()
# Top votes shares
vote_shares[:15]


Out[5]:
Party Votes
0 Bharatiya Janata Party 27.805380
1 Shivsena 19.349126
2 Indian National Congress 17.950624
3 Nationalist Congress Party 17.243942
4 Independent 4.714455
5 Maharashtra Navnirman sena 3.147423
6 Bahujan Samaj Party 2.252771
7 Peasants And Workers Party of India 1.008118
8 All India Majlis-E-Ittehadul Muslimeen 0.925521
9 None of the Above 0.913886
10 Bharipa Bahujan Mahasangh 0.893973
11 Swabhimani Paksha 0.659539
12 Bahujan Vikas Aaghadi 0.622775
13 Rashtriya Samaj Paksha 0.485170
14 Communist Party of India (Marxist) 0.393057

In [6]:
party_contestants = df.groupby('Party').size().order(ascending=False).reset_index()
# Number of contestants
party_contestants[:20]


Out[6]:
Party 0
0 Independent 1700
1 None of the Above 288
2 Indian National Congress 287
3 Shivsena 282
4 Bahujan Samaj Party 280
5 Nationalist Congress Party 278
6 Bharatiya Janata Party 260
7 Maharashtra Navnirman sena 219
8 Bahujan Mukti Party 133
9 Bharipa Bahujan Mahasangh 70
10 Peasants And Workers Party of India 51
11 Ambedkarite Party of India 40
12 Republican Party of India 39
13 Bahujan Vikas Aaghadi 36
14 Communist Party of India 33
15 Republican Sena 26
16 All India Majlis-E-Ittehadul Muslimeen 24
17 Samajwadi Party 22
18 Communist Party of India (Marxist) 20
19 Ambedkarist Republican Party 19

In [7]:
df_win = df.sort(['Constituency-code', 'Votes'], ascending=[1, 0]).groupby('Constituency-code', as_index=False).first()
df_win[:2]


Out[7]:
Constituency-code Candidate Party Votes State Constituency State-code
0 1 PADAVI ADV. K.C. Indian National Congress 64410 Maharashtra Akkalkuwa S13
1 2 PADVI UDESING KOCHARU Bharatiya Janata Party 58556 Maharashtra Shahada S13

In [8]:
#apply(lambda t: t.iloc[1])
runners = df.sort(['Constituency-code', 'Votes'], ascending=[1, 0]).groupby('Constituency-code', as_index=False).nth(1).dropna()
df_win['Margin'] = df_win['Votes'] - runners['Votes'].values # no merge needed cos in same order
df_win['Runnerup-Party'] = runners['Party'].values
df_win[:2]


Out[8]:
Constituency-code Candidate Party Votes State Constituency State-code Margin Runnerup-Party
0 1 PADAVI ADV. K.C. Indian National Congress 64410 Maharashtra Akkalkuwa S13 15775 Nationalist Congress Party
1 2 PADVI UDESING KOCHARU Bharatiya Janata Party 58556 Maharashtra Shahada S13 719 Indian National Congress

In [9]:
party_wins = df_win.groupby('Party').size().order(ascending=False)
# Number of wins
party_wins


Out[9]:
Party
Bharatiya Janata Party                    122
Shivsena                                   63
Indian National Congress                   42
Nationalist Congress Party                 41
Independent                                 7
Peasants And Workers Party of India         3
Bahujan Vikas Aaghadi                       3
All India Majlis-E-Ittehadul Muslimeen      2
Samajwadi Party                             1
Rashtriya Samaj Paksha                      1
Maharashtra Navnirman sena                  1
Communist Party of India  (Marxist)         1
Bharipa Bahujan Mahasangh                   1
dtype: int64

In [10]:
runner_party = df_win.groupby('Runnerup-Party').size().order(ascending=False)
# Number of runner-up positions
runner_party


Out[10]:
Runnerup-Party
Indian National Congress                  71
Shivsena                                  69
Bharatiya Janata Party                    60
Nationalist Congress Party                56
Maharashtra Navnirman sena                 6
Independent                                6
Bharipa Bahujan Mahasangh                  4
Bahujan Samaj Party                        4
Peasants And Workers Party of India        3
All India Majlis-E-Ittehadul Muslimeen     3
Rashtriya Samaj Paksha                     2
Swabhimani Paksha                          1
Republican Party of India                  1
Jan Surajya Shakti                         1
Communist Party of India  (Marxist)        1
dtype: int64

In [11]:
df_alliance = df.copy()
alliances1 = ['Bharatiya Janata Party', 'Shivsena']
alliances2 = ['Indian National Congress', 'Nationalist Congress Party']
df_alliance['alliance'] = df_alliance['Party'].map(lambda x: 'BJP-SS' if x in alliances1 else 'INC-NCP'if x in alliances2 else x)

In [12]:
df_alliance[:4]


Out[12]:
Candidate Party Votes State Constituency State-code Constituency-code alliance
1441 PADAVI ADV. K.C. Indian National Congress 64410 Maharashtra Akkalkuwa S13 1 INC-NCP
1442 PARADAKE VIJAYSING RUPSING Nationalist Congress Party 48635 Maharashtra Akkalkuwa S13 1 INC-NCP
1443 PADAVI NAGESH DILWARSING Bharatiya Janata Party 32701 Maharashtra Akkalkuwa S13 1 BJP-SS
1444 AAMSHYA FULJI PADAVI Shivsena 10349 Maharashtra Akkalkuwa S13 1 BJP-SS

In [13]:
alliance_local = df_alliance.groupby(['Constituency-code', 'Constituency', 'alliance'], as_index=False).sum()

In [14]:
alliance_wins = alliance_local.sort(['Constituency-code', 'Votes'], ascending=[1, 0])\
                .groupby(['Constituency-code', 'Constituency'], as_index=False).first()

In [15]:
# If alliance worked, then wins would be
alliance_wins.groupby('alliance').size().order(ascending=False)


Out[15]:
alliance
BJP-SS                                    203
INC-NCP                                    74
Independent                                 4
Peasants And Workers Party of India         2
Bahujan Vikas Aaghadi                       2
Samajwadi Party                             1
Rashtriya Samaj Paksha                      1
All India Majlis-E-Ittehadul Muslimeen      1
dtype: int64

In [16]:
code_votes = df.groupby('Constituency-code', as_index=False).sum()
code_votes.columns = ['Constituency-code', 'Total-Votes']

In [17]:
df_winp = df_win.merge(code_votes, on='Constituency-code')
df_winp['Win%'] = (100*df_winp['Votes']/df_winp['Total-Votes']).round(2)

In [18]:
# Winners with lower vote shares
df_winp.sort(['Win%'])[:5]


Out[18]:
Constituency-code Candidate Party Votes State Constituency State-code Margin Runnerup-Party Total-Votes Win%
183 184 ADVOCATE WARIS YUSUF PATHAN All India Majlis-E-Ittehadul Muslimeen 25314 Maharashtra Byculla S13 1357 Bharatiya Janata Party 124544 20.33
85 86 D.P.SAWANT Indian National Congress 40356 Maharashtra Nanded North S13 7602 Bharatiya Janata Party 177856 22.69
96 97 MADHUSUDAN MANIKRAO KENDRE Nationalist Congress Party 58415 Maharashtra Gangakhed S13 2289 Rashtriya Samaj Paksha 254885 22.92
75 76 BODKURWAR SANJIVREDDI BAPURAO Bharatiya Janata Party 45178 Maharashtra Wani S13 5606 Shivsena 196164 23.03
270 271 DESAI-KUPAKAR SANDHYADEVI KRUSHNARAO Nationalist Congress Party 51599 Maharashtra Chandgad S13 8199 Shivsena 217590 23.71

In [19]:
# Winners with top vote shares
df_winp.sort(['Win%'], ascending=[0])[:5]


Out[19]:
Constituency-code Candidate Party Votes State Constituency State-code Margin Runnerup-Party Total-Votes Win%
184 185 MANGAL PRABHAT LODHA Bharatiya Janata Party 97818 Maharashtra Malabar hill S13 68686 Shivsena 145886 67.05
90 91 GOVIND MUKKAJI RATHOD Bharatiya Janata Party 118781 Maharashtra Mukhed S13 73291 Indian National Congress 177470 66.93
200 201 AJIT ANANTRAO PAWAR Nationalist Congress Party 150588 Maharashtra Baramati S13 89791 Bharatiya Janata Party 228230 65.98
217 218 RADHAKRISHNA EKNATHRAO VIKHE PATIL Indian National Congress 121459 Maharashtra Shirdi S13 74662 Shivsena 192464 63.11
282 283 JAYANT RAJARAM PATIL Nationalist Congress Party 113045 Maharashtra Islampur S13 75186 Independent 180940 62.48

In [20]:
df_winp['Margin%'] = (100*df_winp['Margin']/df_winp['Total-Votes']).round(2)

In [21]:
# Winners with lowest margin%
df_winp.sort(['Margin%'])[:5]


Out[21]:
Constituency-code Candidate Party Votes State Constituency State-code Margin Runnerup-Party Total-Votes Win% Margin%
192 193 AVDHOOT ANIL TATKARE Nationalist Congress Party 61038 Maharashtra Shrivardhan S13 77 Shivsena 150955 40.43 0.05
243 244 PATIL NARAYAN GOVINDRAO Shivsena 60674 Maharashtra Karmala S13 257 Nationalist Congress Party 202674 29.94 0.13
100 101 ARJUN PANDITRAO KHOTKAR Shivsena 45078 Maharashtra Jalna S13 296 Indian National Congress 177909 25.34 0.17
276 277 SATYAJEET BABASAHEB PATIL (ABA) SARUDKAR Shivsena 74702 Maharashtra Shahuwadi S13 388 Jan Surajya Shakti 209412 35.67 0.19
274 275 NARKE CHANDRADIP SHASHIKANT Shivsena 107998 Maharashtra Karvir S13 710 Indian National Congress 244072 44.25 0.29

In [22]:
# Winners with highest margin%
df_winp.sort(['Margin%'], ascending=[0])[:5]


Out[22]:
Constituency-code Candidate Party Votes State Constituency State-code Margin Runnerup-Party Total-Votes Win% Margin%
184 185 MANGAL PRABHAT LODHA Bharatiya Janata Party 97818 Maharashtra Malabar hill S13 68686 Shivsena 145886 67.05 47.08
247 248 VIJAY SIDRAMAPPA DESHMUKH Bharatiya Janata Party 86877 Maharashtra Solapur City North S13 68878 Nationalist Congress Party 153151 56.73 44.97
151 152 VINOD TAWDE Bharatiya Janata Party 108278 Maharashtra Borivali S13 79267 Shivsena 178976 60.50 44.29
282 283 JAYANT RAJARAM PATIL Nationalist Congress Party 113045 Maharashtra Islampur S13 75186 Independent 180940 62.48 41.55
90 91 GOVIND MUKKAJI RATHOD Bharatiya Janata Party 118781 Maharashtra Mukhed S13 73291 Indian National Congress 177470 66.93 41.30

In [23]:
# with more than 50% voteshare sorted by margin
df_winp[df_winp['Win%']>50].sort('Margin%')[:5]


Out[23]:
Constituency-code Candidate Party Votes State Constituency State-code Margin Runnerup-Party Total-Votes Win% Margin%
268 269 NAIK VAIBHAV VIJAY Shivsena 70582 Maharashtra Kudal S13 10376 Indian National Congress 141066 50.03 7.36
260 261 DESAI SHAMBHURAJ SHIVAJIRAO Shivsena 104419 Maharashtra Patan S13 18824 Nationalist Congress Party 206589 50.54 9.11
119 120 RAJABHAU (PARAG) PRAKASH WAJE Shivsena 104031 Maharashtra Sinnar S13 20554 Bharatiya Janata Party 196720 52.88 10.45
286 287 ADV.R.R. (AABA) ALIAS RAVSAHEB RAMRAO PATIL Nationalist Congress Party 108310 Maharashtra Tasgaon-Kavathe Mahankal S13 22410 Bharatiya Janata Party 205533 52.70 10.90
284 285 DR. KADAM PATANGRAO SHRIPATRAO Indian National Congress 112523 Maharashtra Palus-Kadegaon S13 24034 Bharatiya Janata Party 208584 53.95 11.52

In [24]:
# Parties which won with voteshares > 50%
df_winp[df_winp['Win%']>50].groupby('Party').size().order(ascending=False)


Out[24]:
Party
Bharatiya Janata Party        27
Shivsena                      11
Nationalist Congress Party     9
Indian National Congress       6
Bahujan Vikas Aaghadi          2
dtype: int64

In [25]:
# Parties which won with voteshares < 25%
df_winp[df_winp['Win%']<25].groupby('Party').size().order(ascending=False)


Out[25]:
Party
Bharatiya Janata Party                    4
Nationalist Congress Party                2
Shivsena                                  1
Indian National Congress                  1
Bharipa Bahujan Mahasangh                 1
All India Majlis-E-Ittehadul Muslimeen    1
dtype: int64

In [26]:
# Parties which won with margin < 1%
df_winp[df_winp['Margin%']<1].groupby('Party').size().order(ascending=False)


Out[26]:
Party
Shivsena                      8
Indian National Congress      3
Bharatiya Janata Party        3
Nationalist Congress Party    2
Independent                   1
dtype: int64

In [27]:
df_winp['First-Two'] = 2*df_winp['Votes']-df_winp['Margin']
df_winp['First-Two%'] = (100*df_winp['First-Two']/df_winp['Total-Votes']).round(2)

In [28]:
# Places where first-two had lesser share
df_winp.sort('First-Two%')[:3]


Out[28]:
Constituency-code Candidate Party Votes State Constituency State-code Margin Runnerup-Party Total-Votes Win% Margin% First-Two First-Two%
183 184 ADVOCATE WARIS YUSUF PATHAN All India Majlis-E-Ittehadul Muslimeen 25314 Maharashtra Byculla S13 1357 Bharatiya Janata Party 124544 20.33 1.09 49271 39.56
85 86 D.P.SAWANT Indian National Congress 40356 Maharashtra Nanded North S13 7602 Bharatiya Janata Party 177856 22.69 4.27 73110 41.11
75 76 BODKURWAR SANJIVREDDI BAPURAO Bharatiya Janata Party 45178 Maharashtra Wani S13 5606 Shivsena 196164 23.03 2.86 84750 43.20

In [29]:
# How parties dominated in mostly bi-polar regions?
df_winp[df_winp['First-Two%']>80].groupby('Party').size().order(ascending=False)


Out[29]:
Party
Bharatiya Janata Party                 29
Indian National Congress               14
Shivsena                               12
Nationalist Congress Party             12
Rashtriya Samaj Paksha                  1
Peasants And Workers Party of India     1
Bahujan Vikas Aaghadi                   1
dtype: int64

In [30]:
# How parties dominated in mostly multi-cornered regions?
df_winp[df_winp['First-Two%']<50].groupby('Party').size().order(ascending=False)


Out[30]:
Party
Bharatiya Janata Party                    6
Nationalist Congress Party                2
Independent                               2
Shivsena                                  1
Indian National Congress                  1
Bharipa Bahujan Mahasangh                 1
All India Majlis-E-Ittehadul Muslimeen    1
dtype: int64

In [31]:
# Places where first-two had higher share
df_winp.sort('First-Two%', ascending=False)[:5]


Out[31]:
Constituency-code Candidate Party Votes State Constituency State-code Margin Runnerup-Party Total-Votes Win% Margin% First-Two First-Two%
284 285 DR. KADAM PATANGRAO SHRIPATRAO Indian National Congress 112523 Maharashtra Palus-Kadegaon S13 24034 Bharatiya Janata Party 208584 53.95 11.52 201012 96.37
272 273 MUSHRIF HASAN MIYALAL Nationalist Congress Party 123626 Maharashtra Kagal S13 5934 Shivsena 251452 49.16 2.36 241318 95.97
119 120 RAJABHAU (PARAG) PRAKASH WAJE Shivsena 104031 Maharashtra Sinnar S13 20554 Bharatiya Janata Party 196720 52.88 10.45 187508 95.32
271 272 AABITAKAR PRAKASH ANANDARAO Shivsena 132485 Maharashtra Radhanagari S13 39408 Nationalist Congress Party 236857 55.93 16.64 225562 95.23
286 287 ADV.R.R. (AABA) ALIAS RAVSAHEB RAMRAO PATIL Nationalist Congress Party 108310 Maharashtra Tasgaon-Kavathe Mahankal S13 22410 Bharatiya Janata Party 205533 52.70 10.90 194210 94.49

In [32]:
df = df.merge(code_votes, on='Constituency-code')

In [33]:
df['vote%'] = (100*df['Votes']/df['Total-Votes']).round(2)

# Places where party got less than 5% votes
for party in list(vote_shares['Party'][:10]):
    print party, df[(df['Party']==party) & (df['vote%']<5)].shape[0]


Bharatiya Janata Party 12
Shivsena 54
Indian National Congress 74
Nationalist Congress Party 89
Independent 1652
Maharashtra Navnirman sena 161
Bahujan Samaj Party 246
Peasants And Workers Party of India 43
All India Majlis-E-Ittehadul Muslimeen 8
None of the Above 287

In [34]:
alliance_local = alliance_local.merge(code_votes, on='Constituency-code')

In [35]:
alliance_local['vote%'] = (100*alliance_local['Votes']/alliance_local['Total-Votes']).round(2)

In [36]:
# Even under alliance, BJP-SS would have got less than 10% votes in
alliance_local[(alliance_local['alliance']=='BJP-SS') & (alliance_local['vote%']<10)]


Out[36]:
Constituency-code Constituency alliance Votes Total-Votes vote%
20 4 Nawapur BJP-SS 15213 197826 7.69
1037 114 Malegaon central BJP-SS 1375 167409 0.82
1766 199 Daund BJP-SS 2974 199441 1.49
1775 200 Indapur BJP-SS 6444 218031 2.96
2202 255 Phaltan BJP-SS 15704 200657 7.83
2216 257 Koregaon BJP-SS 15862 178686 8.88
2231 259 Karad North BJP-SS 5657 190466 2.97

In [37]:
# Even under alliance, INC-NCP would have got less than 10% votes in
alliance_local[(alliance_local['alliance']=='INC-NCP') & (alliance_local['vote%']<10)]


Out[37]:
Constituency-code Constituency alliance Votes Total-Votes vote%
94 13 Jalgaon City INC-NCP 8849 187536 4.72
141 20 Muktainagar INC-NCP 10994 183527 5.99
237 31 Akola East INC-NCP 15630 168597 9.27
868 96 Parbhani INC-NCP 18717 190267 9.84
1078 120 Sinnar INC-NCP 5371 196720 2.73
1166 131 Boisar INC-NCP 4005 171271 2.34
1173 132 Nalasopara INC-NCP 4555 225820 2.02
1181 133 Vasai INC-NCP 16467 190629 8.64
1265 143 Dombivali INC-NCP 13394 151283 8.85
1339 152 Borivali INC-NCP 16183 178976 9.04
1356 154 Magathane INC-NCP 14899 162192 9.19
1626 181 Mahim INC-NCP 13136 136259 9.64
1658 185 Malabar hill INC-NCP 12039 145886 8.25
1689 188 Panvel INC-NCP 12001 283372 4.24
2188 253 Sangola INC-NCP 3457 198086 1.75

In [38]:
# Votes share distributions of MNS
df[(df['Party']=='Maharashtra Navnirman sena')]['vote%'].hist()


Out[38]:
<matplotlib.axes.AxesSubplot at 0xa554c18>

In [39]:
# Votes share distributions of MIM
df[(df['Party']=='All India Majlis-E-Ittehadul Muslimeen')]['vote%'].hist()


Out[39]:
<matplotlib.axes.AxesSubplot at 0xbb47cf8>

In [40]:
# high nota regions
notapa=df[(df['Party']=='None of the Above')][['Constituency-code','Constituency','Votes','vote%']]\
    .merge(df_winp[['Candidate','Party','Runnerup-Party','Constituency-code','Votes','Margin','Total-Votes','Win%','Margin%','First-Two','First-Two%']],
           on='Constituency-code', suffixes=('_nota', '_win'))

In [41]:
# Highe NOTA regions
notapa.sort('vote%', ascending=False)[:5]


Out[41]:
Constituency-code Constituency Votes_nota vote% Candidate Party Runnerup-Party Votes_win Margin Total-Votes Win% Margin% First-Two First-Two%
67 68 Gadchiroli 17510 10.80 DR. DEORAO MADGUJI HOLI Bharatiya Janata Party Nationalist Congress Party 70185 51905 162193 43.27 32.00 88465 54.54
68 69 Aheri 7349 4.86 AMBRISHRAO RAJE SATYAVANRAO ATRAM Bharatiya Janata Party Nationalist Congress Party 56418 19858 151246 37.30 13.13 92978 61.47
143 144 Kalyan Rural 7835 4.68 BHOIR SUBHASH GANU Shivsena Maharashtra Navnirman sena 84110 44212 167496 50.22 26.40 124008 74.04
127 128 Dahanu 4498 2.90 DHANARE PASKAL JANYA Bharatiya Janata Party Communist Party of India (Marxist) 44849 16700 154849 28.96 10.78 72998 47.14
163 164 Versova 3266 2.79 DR. BHARATI HEMANT LAVEKAR Bharatiya Janata Party Indian National Congress 49182 26398 117268 41.94 22.51 71966 61.37

In [42]:
# Big NOTA affect at 20 places, places where candidate won by margin < NOTA votes
notapa[notapa['Votes_nota']>notapa['Margin']].sort('Margin%')


Out[42]:
Constituency-code Constituency Votes_nota vote% Candidate Party Runnerup-Party Votes_win Margin Total-Votes Win% Margin% First-Two First-Two%
192 193 Shrivardhan 3562 2.36 AVDHOOT ANIL TATKARE Nationalist Congress Party Shivsena 61038 77 150955 40.43 0.05 121999 80.82
243 244 Karmala 734 0.36 PATIL NARAYAN GOVINDRAO Shivsena Nationalist Congress Party 60674 257 202674 29.94 0.13 121091 59.75
100 101 Jalna 1346 0.76 ARJUN PANDITRAO KHOTKAR Shivsena Indian National Congress 45078 296 177909 25.34 0.17 89860 50.51
276 277 Shahuwadi 1024 0.49 SATYAJEET BABASAHEB PATIL (ABA) SARUDKAR Shivsena Jan Surajya Shakti 74702 388 209412 35.67 0.19 149016 71.16
274 275 Karvir 789 0.32 NARKE CHANDRADIP SHASHIKANT Shivsena Indian National Congress 107998 710 244072 44.25 0.29 215286 88.21
129 130 Palghar 2987 1.82 GHODA KRUSHNA ARJUN Shivsena Indian National Congress 46142 515 164116 28.12 0.31 91769 55.92
1 2 Shahada 2755 1.48 PADVI UDESING KOCHARU Bharatiya Janata Party Indian National Congress 58556 719 186613 31.38 0.39 116393 62.37
189 190 Uran 1199 0.61 MANOHAR GAJANAN BHOIR Shivsena Peasants And Workers Party of India 56131 811 197893 28.36 0.41 111451 56.32
141 142 Kalyan East 2720 1.92 GANPAT KALU GAIKWAD Independent Shivsena 36357 745 141397 25.71 0.53 71969 50.90
179 180 Wadala 1624 1.34 KALIDAS NILKANTH KOLAMBKAR Indian National Congress Bharatiya Janata Party 38540 800 120878 31.88 0.66 76280 63.10
171 172 Anushakti Nagar 1577 1.17 TUKARAM RAMKRISHNA KATE Shivsena Nationalist Congress Party 39966 1007 135289 29.54 0.74 78925 58.34
150 151 Belapur 1944 1.02 MANDA VIJAY MHATRE Bharatiya Janata Party Nationalist Congress Party 55316 1491 190206 29.08 0.78 109141 57.38
104 105 Kannad 2094 1.09 JADHAV HARSHVARDHAN RAIBHAN Shivsena Nationalist Congress Party 62542 1561 191781 32.61 0.81 123523 64.41
174 175 Kalina 1766 1.39 SANJAY GOVIND POTNIS Shivsena Bharatiya Janata Party 30715 1297 126845 24.21 1.02 60133 47.41
188 189 Karjat 2521 1.38 SURESHBHAU NARAYAN LAD Nationalist Congress Party Peasants And Workers Party of India 57013 1900 183223 31.12 1.04 112126 61.20
183 184 Byculla 1620 1.30 ADVOCATE WARIS YUSUF PATHAN All India Majlis-E-Ittehadul Muslimeen Bharatiya Janata Party 25314 1357 124544 20.33 1.09 49271 39.56
40 41 Melghat 3567 2.03 BHILAWEKAR PRABHDAS BABULAL Bharatiya Janata Party Nationalist Congress Party 57002 1979 175700 32.44 1.13 112025 63.76
205 206 Pimpri 4435 2.51 ADV. CHABUKSWAR GAUTAM SUKHDEO Shivsena Nationalist Congress Party 51096 2335 176902 28.88 1.32 99857 56.45
139 140 Ambernath 2288 1.68 DR. BALAJI KINIKAR Shivsena Bharatiya Janata Party 47000 2041 136563 34.42 1.49 91959 67.34
128 129 Vikramgad 4188 2.53 SAVARA VISHNU RAMA Bharatiya Janata Party Shivsena 40201 3845 165524 24.29 2.32 76557 46.25

In [43]:
# At these NOTA places, Shivsena won by a NOTA-whisker
notapa[notapa['Votes_nota']>notapa['Margin']].groupby('Party').size().order(ascending=False)


Out[43]:
Party
Shivsena                                  11
Bharatiya Janata Party                     4
Nationalist Congress Party                 2
Indian National Congress                   1
Independent                                1
All India Majlis-E-Ittehadul Muslimeen     1
dtype: int64

In [44]:
PARTIES = alliances1 + alliances2 + ['None of the Above', 'All India Majlis-E-Ittehadul Muslimeen', 'Maharashtra Navnirman sena']
df_pivot_p = df[df['Party'].isin(PARTIES)].pivot(index='Constituency-code', columns='Party', values='Votes').reset_index()
df_pivot_p[:2]


Out[44]:
Party Constituency-code All India Majlis-E-Ittehadul Muslimeen Bharatiya Janata Party Indian National Congress Maharashtra Navnirman sena Nationalist Congress Party None of the Above Shivsena
0 1 NaN 32701 64410 2026 48635 4161 10349
1 2 NaN 58556 57837 4410 46966 2755 6645

In [45]:
df_pivot_p = df_winp.merge(df_pivot_p, on='Constituency-code')

In [46]:
df_pivot_p[:2]


Out[46]:
Constituency-code Candidate Party Votes State Constituency State-code Margin Runnerup-Party Total-Votes ... Margin% First-Two First-Two% All India Majlis-E-Ittehadul Muslimeen Bharatiya Janata Party Indian National Congress Maharashtra Navnirman sena Nationalist Congress Party None of the Above Shivsena
0 1 PADAVI ADV. K.C. Indian National Congress 64410 Maharashtra Akkalkuwa S13 15775 Nationalist Congress Party 175092 ... 9.01 113045 64.56 NaN 32701 64410 2026 48635 4161 10349
1 2 PADVI UDESING KOCHARU Bharatiya Janata Party 58556 Maharashtra Shahada S13 719 Indian National Congress 186613 ... 0.39 116393 62.37 NaN 58556 57837 4410 46966 2755 6645

2 rows × 21 columns


In [47]:
combi = ['Shivsena', 'Maharashtra Navnirman sena']
df_sena_miss = df_pivot_p[((df_pivot_p[combi[0]].fillna(0) + df_pivot_p[combi[1]].fillna(0)) >
                          df_pivot_p['Votes']) &
                          (~df_pivot_p['Party'].isin(combi))]

In [48]:
print "SS-MNS additionally won - ", df_sena_miss.shape[0]
print "from"
df_sena_miss.groupby('Party').size().order(ascending=False)


SS-MNS additionally won -  15
from
Out[48]:
Party
Bharatiya Janata Party        8
Nationalist Congress Party    5
Indian National Congress      1
Independent                   1
dtype: int64

In [49]:
combi = ['All India Majlis-E-Ittehadul Muslimeen', 'Indian National Congress']
df_inc_mim = df_pivot_p[((df_pivot_p[combi[0]].fillna(0) + df_pivot_p[combi[1]].fillna(0)) >
                          df_pivot_p['Votes']) &
                          (~df_pivot_p['Party'].isin(combi))]
df_inc_mim


Out[49]:
Constituency-code Candidate Party Votes State Constituency State-code Margin Runnerup-Party Total-Votes ... Margin% First-Two First-Two% All India Majlis-E-Ittehadul Muslimeen Bharatiya Janata Party Indian National Congress Maharashtra Navnirman sena Nationalist Congress Party None of the Above Shivsena
86 87 HEMANT SRIRAM PATIL Shivsena 45836 Maharashtra Nanded South S13 3207 Bharatiya Janata Party 174229 ... 1.84 88465 50.78 34590 42629 31762 1812 984 495 45836
108 109 ATUL MORESHWAR SAVE Bharatiya Janata Party 64528 Maharashtra Aurangabad East S13 4260 All India Majlis-E-Ittehadul Muslimeen 175422 ... 2.43 124796 71.14 60268 64528 21203 1419 2121 786 11409
135 136 CHOUGHULE MAHESH PRABHAKAR Bharatiya Janata Party 42483 Maharashtra Bhiwandi West S13 3326 Indian National Congress 124975 ... 2.66 81640 65.33 4686 42483 39157 NaN 16131 799 20106

3 rows × 21 columns


In [50]:
combi = ['All India Majlis-E-Ittehadul Muslimeen', 'Nationalist Congress Party']
df_ncp_mim = df_pivot_p[((df_pivot_p[combi[0]].fillna(0) + df_pivot_p[combi[1]].fillna(0)) >
                          df_pivot_p['Votes']) &
                          (~df_pivot_p['Party'].isin(combi))]
df_ncp_mim


Out[50]:
Constituency-code Candidate Party Votes State Constituency State-code Margin Runnerup-Party Total-Votes ... Margin% First-Two First-Two% All India Majlis-E-Ittehadul Muslimeen Bharatiya Janata Party Indian National Congress Maharashtra Navnirman sena Nationalist Congress Party None of the Above Shivsena
85 86 D.P.SAWANT Indian National Congress 40356 Maharashtra Nanded North S13 7602 Bharatiya Janata Party 177856 ... 4.27 73110 41.11 32333 32754 40356 5330 10857 727 23103
113 114 SHAIKH AASIF SHAIKH RASHID Indian National Congress 75326 Maharashtra Malegaon central S13 16151 Nationalist Congress Party 167409 ... 9.65 134501 80.34 21050 NaN 75326 NaN 59175 1259 1375

2 rows × 21 columns


In [51]:
combi = ['Indian National Congress', 'Nationalist Congress Party']
df_inc_ncp = df_pivot_p[((df_pivot_p[combi[0]].fillna(0) + df_pivot_p[combi[1]].fillna(0)) >
                          df_pivot_p['Votes']) &
                          (~df_pivot_p['Party'].isin(combi))]
print "INC-NCP additionally would have won", df_inc_ncp.shape[0]
print "eating from"
df_inc_ncp.groupby('Party').size().order(ascending=False)


INC-NCP additionally would have won 37
eating from
Out[51]:
Party
Bharatiya Janata Party                 20
Shivsena                               12
Independent                             2
Peasants And Workers Party of India     1
Communist Party of India  (Marxist)     1
Bharipa Bahujan Mahasangh               1
dtype: int64

In [52]:
combi = ['Bharatiya Janata Party', 'Shivsena']
df_bjp_ss = df_pivot_p[((df_pivot_p[combi[0]].fillna(0) + df_pivot_p[combi[1]].fillna(0)) >
                          df_pivot_p['Votes']) &
                          (~df_pivot_p['Party'].isin(combi))]
print "BJP-SS would have won extra", df_bjp_ss.shape[0]
print "eating from"
df_bjp_ss.groupby('Party').size().order(ascending=False)


BJP-SS would have won extra 42
eating from
Out[52]:
Party
Indian National Congress                  19
Nationalist Congress Party                17
Independent                                3
Maharashtra Navnirman sena                 1
Bahujan Vikas Aaghadi                      1
All India Majlis-E-Ittehadul Muslimeen     1
dtype: int64

In [53]:
top_independents = df[df['Party']=='Independent'].groupby('Constituency-code', as_index=False).first()

In [54]:
# At places where top independent got < 5% vote share
top_independents[top_independents['vote%']<5].shape[0]


Out[54]:
236

In [55]:
# At places where top independent got > 20% vote share
top_independents[top_independents['vote%']>20].shape[0]


Out[55]:
15

Find anything interesting? Fork, add and submit =)