# Nigerian Presidential Election Result Analysis - 2015¶

### Data Source¶

The data was gathered from the Independent National Electoral Commission (INEC) official website.

Am going to use these three main python programming packages pandas with matplotlib embedded to analyse the 2015 Presidential Election Result.

# Introduction¶

Nigeria has 36 states and 1 federal capital territory. The 2015 presidential election was held in the 37 territories within the country.

Fourteen (14) political parties representing fourteen (14) candidates participated in the 2015 presidential elections. The parties are as follow: AA, ACPN, AD, ADC, APA, APC, CPP, HOPE, KOWA, NCP, PDP, PPN, UDP and UPP. See the result table below:-

Even though the battle was between the two biggest parties (APC and PDP). The dataset we will explore will contain all the parties.

The dataset contains the numeric values by states for:-
1~ Vote scored by each political party
2~ Number_of_Registered_Voters
3~ Number_of_Accredited_Voters
7~ Population
8~ Population_Rank
9~ Number_of_LGA

#### I will attempt to answer the following questions through this analysis:-¶

a) What are the minimum and maximum votes for each party?
b) Is winning in top states with highest numbers of voters’ turnout, registered voters, total votes cast, and population related to winning the general election?
c) Is there any odd case where "Population" of a state is lower than "Number_of_Registered_Voters" and "Number_of_Accredited_Voters"?
d) Which state voted most for the lowest rank party?

#### Import libraries and load in the dataset¶

In [1]:
# Lets import the packages
import pandas as pd

# Lets enable our plot to display inline within notebook
%matplotlib inline

In [2]:
inec_table = pd.read_csv("INEC 2015 Presidential Election Results.csv")

Out[2]:
0 Abia Umuahia AB 1349134 442538 315 2194 448 569 2766 ... 213 330 391045 10004 401049 2833999 28 17 5.614284 7.552007
1 Adamawa Yola AD 1518123 709993 495 1166 595 1012 1549 ... 289 334 636018 25192 661210 3168101 26 21 9.562175 12.562022
2 Akwa Ibom Uyo AK 1644481 1074070 1600 443 474 608 384 ... 224 144 1017064 11487 1028551 3920208 15 31 4.832722 7.812528
3 Anambra Awka AN 1963427 774430 547 1259 475 534 2303 ... 286 1121 688584 14825 703409 4182032 10 21 6.235526 6.970846
4 Bauchi Bauchi BA 2053484 1094069 131 232 173 189 964 ... 29 37 1020338 19437 1039775 4676465 7 20 10.544138 9.576053

5 rows × 27 columns

### Statistical summary of all the columns¶

This will show us the minimum and maximum votes for each party.

In [3]:
inec_table.describe()

Out[3]:
count 3.700000e+01 3.700000e+01 37.000000 37.000000 37.000000 37.000000 37.000000 3.700000e+01 37.000000 37.000000 ... 37.000000 37.000000 3.700000e+01 37.000000 3.700000e+01 3.700000e+01 37.000000 37.000000 37.000000 37.000000
mean 1.822218e+06 8.580132e+05 597.972973 1089.486486 829.000000 801.783784 1446.945946 4.168895e+05 981.081081 200.945946 ... 248.864865 492.432432 7.726369e+05 22824.837838 7.954617e+05 3.783880e+06 19.000000 20.918919 8.573171 7.335358
std 1.026219e+06 4.641212e+05 1058.202944 1537.150658 1193.011688 893.409143 994.589389 4.137989e+05 1098.046583 208.625388 ... 307.701800 1008.016026 4.245404e+05 11468.557038 4.310620e+05 1.713420e+06 10.824355 7.488430 2.623850 2.427991
min 6.056370e+05 3.237390e+05 40.000000 38.000000 69.000000 105.000000 70.000000 5.194000e+03 44.000000 4.000000 ... 20.000000 29.000000 3.006910e+05 4672.000000 3.094450e+05 1.405201e+06 1.000000 6.000000 4.832722 3.263435
25% 1.349134e+06 5.201270e+05 159.000000 391.000000 279.000000 375.000000 674.000000 1.203310e+05 381.000000 83.000000 ... 79.000000 72.000000 4.737960e+05 14825.000000 4.917670e+05 2.833999e+06 10.000000 17.000000 6.455966 5.928762
50% 1.644481e+06 7.099930e+05 315.000000 538.000000 474.000000 539.000000 1165.000000 3.082900e+05 819.000000 144.000000 ... 184.000000 156.000000 6.426150e+05 19867.000000 6.633730e+05 3.423535e+06 19.000000 20.000000 8.219491 7.091086
75% 1.977211e+06 1.074070e+06 533.000000 1214.000000 735.000000 888.000000 2177.000000 5.678830e+05 1046.000000 255.000000 ... 286.000000 290.000000 9.823880e+05 29449.000000 1.000692e+06 4.182032e+06 28.000000 25.000000 10.564178 8.513930
max 5.827846e+06 2.364434e+06 6331.000000 8979.000000 6282.000000 5000.000000 4468.000000 1.903999e+06 6674.000000 989.000000 ... 1623.000000 4859.000000 2.128821e+06 52289.000000 2.172447e+06 9.383682e+06 37.000000 44.000000 13.109266 12.722342

8 rows × 24 columns

### Turnout of Voters for the election¶

We can see the ratio of voters turnout for the election by dividing "Number_of_Reg_Voters" by "Total_Votes_Cast" for each state

In [4]:
inec_table["Voters Turnout"] = inec_table["Total_Votes_Cast"] / inec_table["Number_of_Reg_Voters"]

inec_table[["State", "Voters Turnout"]][:11]

Out[4]:
State Voters Turnout
0 Abia 0.297264
2 Akwa Ibom 0.625456
3 Anambra 0.358256
4 Bauchi 0.506347
5 Bayelsa 0.613798
6 Benue 0.371320
7 Borno 0.286168
8 Cross River 0.407158
9 Delta 0.628481
10 Ebonyi 0.367184
In [5]:
inec_table.plot(x="State", y='Voters Turnout', figsize=(20, 5), kind="line", grid=1)

Out[5]:
<matplotlib.axes._subplots.AxesSubplot at 0x8723ba8>

### Five top states with the highest "Number_of_Reg_Voters"¶

In [6]:
inec_table.sort_values("Number_of_Reg_Voters", ascending=False)[:5]

Out[6]:
24 Lagos Ikeja LA 5827846 1678754 1795 3038 4453 2072 2177 ... 244 1443686 52289 1495975 9013534 2 20 6.455966 3.263435 0.256694
19 Kano Kano KN 4943862 2364434 426 778 708 657 2770 ... 156 2128821 43626 2172447 9383682 1 44 12.107263 8.353610 0.439423
18 Kaduna Kaduna KD 3361793 1746031 218 424 273 546 1611 ... 78 1617482 32719 1650201 6066562 3 23 10.704459 7.331567 0.490869
20 Katsina Katsina KT 2842741 1578646 183 402 283 498 1671 ... 72 1449426 32288 1481714 5792578 4 34 13.029105 7.491887 0.521227
30 Oyo Ibadan OY 2344448 1073849 6331 8979 6282 5000 4468 ... 3665 881352 47254 928606 5591589 5 33 8.219491 3.744396 0.396087

5 rows × 28 columns

#### Which party got the highest vote among the top states with the highest "Number_of_Reg_Voters"¶

In [7]:
win1 = inec_table.sort_values("Number_of_Reg_Voters", ascending=False)[:5]

win1.plot(x="State", y=['AA', 'ACPN', 'AD', 'ADC', 'APA', 'APC', 'CPP', 'HOPE', 'KOWA', 'NCP', 'PDP', 'PPN', 'UDP', 'UPP'],
figsize=(20, 5), kind="bar", grid=1)

Out[7]:
<matplotlib.axes._subplots.AxesSubplot at 0x87e6710>

### Five top states with the highest number of "Total_Votes_Cast"¶

In [8]:
inec_table.sort_values("Total_Votes_Cast", ascending=False)[:5]

Out[8]:
19 Kano Kano KN 4943862 2364434 426 778 708 657 2770 ... 156 2128821 43626 2172447 9383682 1 44 12.107263 8.353610 0.439423
18 Kaduna Kaduna KD 3361793 1746031 218 424 273 546 1611 ... 78 1617482 32719 1650201 6066562 3 23 10.704459 7.331567 0.490869
32 Rivers Port Harcourt RV 2324300 1643409 1066 525 1104 1031 513 ... 156 1565461 19307 1584768 5185400 6 23 4.973002 6.810525 0.681826
24 Lagos Ikeja LA 5827846 1678754 1795 3038 4453 2072 2177 ... 244 1443686 52289 1495975 9013534 2 20 6.455966 3.263435 0.256694
20 Katsina Katsina KT 2842741 1578646 183 402 283 498 1671 ... 72 1449426 32288 1481714 5792578 4 34 13.029105 7.491887 0.521227

5 rows × 28 columns

#### Which party got the highest vote among the top states with the highest "Total_Votes_Cast"¶

In [9]:
win2 = inec_table.sort_values("Total_Votes_Cast", ascending=False)[:5]

win2.plot(x="State", y=['AA', 'ACPN', 'AD', 'ADC', 'APA', 'APC', 'CPP', 'HOPE', 'KOWA', 'NCP', 'PDP', 'PPN', 'UDP', 'UPP'],
figsize=(20, 5), kind="bar", grid=1)

Out[9]:
<matplotlib.axes._subplots.AxesSubplot at 0x8b70ac8>

### Five top states with the highest "Population"¶

In [10]:
inec_table.sort_values("Population", ascending=False)[:5]

Out[10]:
19 Kano Kano KN 4943862 2364434 426 778 708 657 2770 ... 156 2128821 43626 2172447 9383682 1 44 12.107263 8.353610 0.439423
24 Lagos Ikeja LA 5827846 1678754 1795 3038 4453 2072 2177 ... 244 1443686 52289 1495975 9013534 2 20 6.455966 3.263435 0.256694
18 Kaduna Kaduna KD 3361793 1746031 218 424 273 546 1611 ... 78 1617482 32719 1650201 6066562 3 23 10.704459 7.331567 0.490869
20 Katsina Katsina KT 2842741 1578646 183 402 283 498 1671 ... 72 1449426 32288 1481714 5792578 4 34 13.029105 7.491887 0.521227
30 Oyo Ibadan OY 2344448 1073849 6331 8979 6282 5000 4468 ... 3665 881352 47254 928606 5591589 5 33 8.219491 3.744396 0.396087

5 rows × 28 columns

#### Which party got the highest vote among the top states with the highest "Population"¶

In [11]:
win3 = inec_table.sort_values("Population", ascending=False)[:5]

win3.plot(x="State", y=['AA', 'ACPN', 'AD', 'ADC', 'APA', 'APC', 'CPP', 'HOPE', 'KOWA', 'NCP', 'PDP', 'PPN', 'UDP', 'UPP'],
figsize=(20, 5), kind="bar", grid=1)

Out[11]:
<matplotlib.axes._subplots.AxesSubplot at 0x982b908>

### Five top states with the highest "Number_of_LGA"¶

In [12]:
inec_table.sort_values("Number_of_LGA", ascending=False)[:5]

Out[12]:
19 Kano Kano KN 4943862 2364434 426 778 708 657 2770 ... 156 2128821 43626 2172447 9383682 1 44 12.107263 8.353610 0.439423
20 Katsina Katsina KT 2842741 1578646 183 402 283 498 1671 ... 72 1449426 32288 1481714 5792578 4 34 13.029105 7.491887 0.521227
30 Oyo Ibadan OY 2344448 1073849 6331 8979 6282 5000 4468 ... 3665 881352 47254 928606 5591589 5 33 8.219491 3.744396 0.396087
2 Akwa Ibom Uyo AK 1644481 1074070 1600 443 474 608 384 ... 144 1017064 11487 1028551 3920208 15 31 4.832722 7.812528 0.625456
29 Osun Oshogbo OS 1378113 683169 377 1731 1667 937 1306 ... 159 642615 20758 663373 3423535 19 30 7.578210 4.485878 0.481363

5 rows × 28 columns

#### Which party got the highest vote among the top states with the highest "Number_of_LGA"¶

In [13]:
win4 = inec_table.sort_values("Number_of_LGA", ascending=False)[:5]

win4.plot(x="State", y=['AA', 'ACPN', 'AD', 'ADC', 'APA', 'APC', 'CPP', 'HOPE', 'KOWA', 'NCP', 'PDP', 'PPN', 'UDP', 'UPP'],
figsize=(20, 5), kind="bar", grid=1)

Out[13]:
<matplotlib.axes._subplots.AxesSubplot at 0x8854828>

### Lets extract the following columns out to form a separate dataframe from the dataset¶

1~ Number_of_Registered_Voters
2~ Number_of_Accredited_Voters
6~ Population
7~ Population_Rank
8~ Number_of_LGA

In [14]:
voters_table = inec_table[['State', 'Number_of_Reg_Voters', 'Number_of_Accr_Voters', 'Number_of_Valid_Votes', 'Number_of_Rejected_Votes',
voters_table

Out[14]:
0 Abia 1349134 442538 391045 10004 10004 401049 2833999 28 17
1 Adamawa 1518123 709993 636018 25192 25192 661210 3168101 26 21
2 Akwa Ibom 1644481 1074070 1017064 11487 11487 1028551 3920208 15 31
3 Anambra 1963427 774430 688584 14825 14825 703409 4182032 10 21
4 Bauchi 2053484 1094069 1020338 19437 19437 1039775 4676465 7 20
5 Bayelsa 605637 384789 367067 4672 4672 371739 1703358 36 8
6 Benue 1893596 754634 683264 19867 19867 703131 4219244 9 23
7 Borno 1799669 544759 501920 13088 13088 515008 4151193 11 27
8 Cross River 1144288 500577 450514 15392 15392 465906 2888966 27 18
9 Delta 2044372 1350914 1267773 17075 17075 1284848 4098391 12 25
10 Ebonyi 1071226 425301 363888 29449 29449 393337 2173501 34 13
11 Edo 1650552 599166 500451 22334 22334 522785 3218332 24 18
12 Ekiti 723255 323739 300691 8754 8754 309445 2384212 29 16
13 Enugu 1381563 616112 573173 12459 12459 585632 3257298 22 17
14 Federal Capital Territory 886573 344056 306805 9210 9210 316015 1405201 37 6
15 Gombe 1110105 515828 460599 12845 12845 473444 2353879 31 11
16 Imo 1747681 801712 702964 28957 28957 731921 3934899 14 27
17 Jigawa 1815889 1153428 1037564 34325 34325 1071889 4348649 8 27
18 Kaduna 3361793 1746031 1617482 32719 32719 1650201 6066562 3 23
19 Kano 4943862 2364434 2128821 43626 43626 2172447 9383682 1 44
20 Katsina 2842741 1578646 1449426 32288 32288 1481714 5792578 4 34
21 Kebbi 1457763 792817 677003 38119 38119 715122 3238628 23 21
22 Kogi 1350883 476839 421328 17959 17959 439287 3278487 20 21
23 Kwara 1181032 489360 440080 21321 21321 461401 2371089 30 16
24 Lagos 5827846 1678754 1443686 52289 52289 1495975 9013534 2 20
25 Nasarawa 1222054 562959 511547 10094 10094 521641 1863275 35 13
26 Niger 1995679 933607 813671 31012 31012 844683 3950249 13 25
27 Ogun 1709409 594975 533172 26441 26441 559613 3728098 16 20
28 Ondo 1501549 618040 561056 21379 21379 582435 3441024 18 18
29 Osun 1378113 683169 642615 20758 20758 663373 3423535 19 30
30 Oyo 2344448 1073849 881352 47254 47254 928606 5591589 5 33
31 Plateau 1977211 1076833 982388 18304 18304 1000692 3178712 25 17
32 Rivers 2324300 1643409 1565461 19307 19307 1584768 5185400 6 23
33 Sokoto 1663127 988899 834259 42110 42110 876369 3696999 17 23
34 Taraba 1374307 638578 579677 23039 23039 602716 2300736 33 16
35 Yobe 1077942 520127 473796 17971 17971 491767 2321591 32 17
36 Zamfara 1484941 875049 761022 19157 19157 780179 3259846 21 14

### Summary statistics of voters_table¶

In [15]:
voters_table.describe()

Out[15]:
count 3.700000e+01 3.700000e+01 3.700000e+01 37.000000 37.000000 3.700000e+01 3.700000e+01 37.000000 37.000000
mean 1.822218e+06 8.580132e+05 7.726369e+05 22824.837838 22824.837838 7.954617e+05 3.783880e+06 19.000000 20.918919
std 1.026219e+06 4.641212e+05 4.245404e+05 11468.557038 11468.557038 4.310620e+05 1.713420e+06 10.824355 7.488430
min 6.056370e+05 3.237390e+05 3.006910e+05 4672.000000 4672.000000 3.094450e+05 1.405201e+06 1.000000 6.000000
25% 1.349134e+06 5.201270e+05 4.737960e+05 14825.000000 14825.000000 4.917670e+05 2.833999e+06 10.000000 17.000000
50% 1.644481e+06 7.099930e+05 6.426150e+05 19867.000000 19867.000000 6.633730e+05 3.423535e+06 19.000000 20.000000
75% 1.977211e+06 1.074070e+06 9.823880e+05 29449.000000 29449.000000 1.000692e+06 4.182032e+06 28.000000 25.000000
max 5.827846e+06 2.364434e+06 2.128821e+06 52289.000000 52289.000000 2.172447e+06 9.383682e+06 37.000000 44.000000

### Graph "Number_of_Registered_Voters" Vs "Number_of_Accredited_Voters" Vs "Population"¶

Naturally, "Number_of_Registered_Voters" should be higher than "Number_of_Accredited_Voters". Likewise, "Population" should be higher than both "Number_of_Registered_Voters" and "Number_of_Accredited_Voters". Lets see if there is any odd case in any particular state?

In [16]:
voters_table.plot(x='State', y=['Number_of_Reg_Voters', 'Number_of_Accr_Voters', 'Population'], kind='bar', figsize=(20, 5), title='Bar Plot', grid=1)

Out[16]:
<matplotlib.axes._subplots.AxesSubplot at 0xa2bcbe0>

### Lets extract the parties columns out to form a separate dataframe from the dataset¶

In [17]:
parties_table = inec_table[['State', 'AA', 'ACPN', 'AD', 'ADC', 'APA', 'APC', 'CPP', 'HOPE', 'KOWA', 'NCP', 'PDP', 'PPN', 'UDP', 'UPP']]

parties_table

Out[17]:
State AA ACPN AD ADC APA APC CPP HOPE KOWA NCP PDP PPN UDP UPP
0 Abia 315 2194 448 569 2766 13394 1046 125 173 745 368303 424 213 330
1 Adamawa 495 1166 595 1012 1549 374701 819 267 752 1212 251664 1163 289 334
2 Akwa Ibom 1600 443 474 608 384 58411 412 192 160 381 953304 327 224 144
3 Anambra 547 1259 475 534 2303 17926 1279 357 311 887 660762 537 286 1121
4 Bauchi 131 232 173 189 964 931598 391 46 128 207 86085 128 29 37
5 Bayelsa 45 38 69 116 70 5194 44 18 52 95 361209 62 20 35
6 Benue 315 1464 254 539 945 373961 567 115 105 683 303737 439 66 74
7 Borno 145 243 392 201 878 473543 310 88 158 107 25640 143 31 41
8 Cross River 279 514 709 749 532 28358 381 237 312 930 414863 864 289 1487
9 Delta 1473 916 735 888 478 48910 813 166 311 670 1211405 393 354 261
10 Ebonyi 426 1214 1133 2704 2452 19518 2345 989 913 1890 323653 1168 624 4859
11 Edo 159 1284 450 512 709 208469 325 22 175 516 286869 729 160 72
12 Ekiti 94 538 854 424 482 120331 330 94 108 377 176466 388 60 145
13 Enugu 441 479 269 478 715 14157 237 110 203 761 553003 407 1623 290
14 Federal Capital Territory 139 342 240 288 674 146399 347 83 165 473 157195 269 95 96
15 Gombe 104 192 169 247 773 361245 407 46 97 227 96873 157 25 37
16 Imo 533 956 757 1617 2236 133253 733 157 158 784 559185 414 264 1917
17 Jigawa 394 540 587 375 2527 885988 1553 337 423 548 142904 853 338 197
18 Kaduna 218 424 273 546 1611 1127760 824 105 176 754 484085 549 79 78
19 Kano 426 778 708 657 2770 1903999 1552 292 288 697 215779 485 234 156
20 Katsina 183 402 283 498 1671 1345441 976 47 215 330 98937 254 117 72
21 Kebbi 214 361 450 472 2685 567883 1794 213 448 519 100972 547 207 238
22 Kogi 700 1089 427 761 1001 264851 967 144 190 399 149987 476 180 156
23 Kwara 248 817 520 438 1165 302146 910 118 214 394 132602 325 81 102
24 Lagos 1795 3038 4453 2072 2177 792460 1125 255 1000 1430 632327 1041 269 244
25 Nasarawa 40 95 74 105 310 236838 131 4 48 222 273460 164 23 33
26 Niger 307 441 403 614 2006 657678 1264 198 305 550 149222 449 116 118
27 Ogun 584 3072 1927 1364 1930 308290 978 332 432 815 207950 4339 562 597
28 Ondo 386 2406 1237 1227 1139 299889 1012 184 223 846 251368 734 184 221
29 Osun 377 1731 1667 937 1306 383603 1029 132 255 767 249929 599 124 159
30 Oyo 6331 8979 6282 5000 4468 528620 6674 839 1312 1895 303376 2842 1069 3665
31 Plateau 178 391 279 406 618 429140 237 56 138 693 549615 554 54 29
32 Rivers 1066 525 1104 1031 513 69238 577 542 2274 565 1487075 492 303 156
33 Sokoto 249 535 714 762 3482 671926 1894 283 475 686 152199 605 269 180
34 Taraba 962 811 586 320 1306 261326 1033 161 153 876 310800 680 224 439
35 Yobe 101 164 213 112 632 446265 329 67 104 120 25526 101 30 32
36 Zamfara 125 238 290 294 1310 612202 655 14 122 404 144833 374 93 68

### Summary statistics of parties_table¶

In [18]:
parties_table.describe()

Out[18]:
AA ACPN AD ADC APA APC CPP HOPE KOWA NCP PDP PPN UDP UPP
count 37.000000 37.000000 37.000000 37.000000 37.000000 3.700000e+01 37.000000 37.000000 37.000000 37.000000 3.700000e+01 37.000000 37.000000 37.000000
mean 597.972973 1089.486486 829.000000 801.783784 1446.945946 4.168895e+05 981.081081 200.945946 353.405405 660.945946 3.473828e+05 661.486486 248.864865 492.432432
std 1058.202944 1537.150658 1193.011688 893.409143 994.589389 4.137989e+05 1098.046583 208.625388 425.865489 418.460336 3.159930e+05 780.911704 307.701800 1008.016026
min 40.000000 38.000000 69.000000 105.000000 70.000000 5.194000e+03 44.000000 4.000000 48.000000 95.000000 2.552600e+04 62.000000 20.000000 29.000000
25% 159.000000 391.000000 279.000000 375.000000 674.000000 1.203310e+05 381.000000 83.000000 153.000000 394.000000 1.492220e+05 327.000000 79.000000 72.000000
50% 315.000000 538.000000 474.000000 539.000000 1165.000000 3.082900e+05 819.000000 144.000000 203.000000 670.000000 2.516640e+05 476.000000 184.000000 156.000000
75% 533.000000 1214.000000 735.000000 888.000000 2177.000000 5.678830e+05 1046.000000 255.000000 312.000000 784.000000 4.148630e+05 680.000000 286.000000 290.000000
max 6331.000000 8979.000000 6282.000000 5000.000000 4468.000000 1.903999e+06 6674.000000 989.000000 2274.000000 1895.000000 1.487075e+06 4339.000000 1623.000000 4859.000000

### Sum of Votes gotten by each party¶

In [19]:
vote_sum = parties_table[['AA', 'ACPN', 'AD', 'ADC', 'APA', 'APC', 'CPP', 'HOPE', 'KOWA', 'NCP', 'PDP', 'PPN', 'UDP', 'UPP']].sum()

vote_sum

Out[19]:
AA         22125
ACPN       40311
APA        53537
APC     15424911
CPP        36300
HOPE        7435
KOWA       13076
NCP        24455
PDP     12853162
PPN        24475
UDP         9208
UPP        18220
dtype: int64

### Visualize the total votes by party¶

In [20]:
vote_sum.plot(kind='bar', figsize=(20, 5), grid=1)

Out[20]:
<matplotlib.axes._subplots.AxesSubplot at 0xb635e48>

### Visualize votes of "APC" and "PDP" by states¶

In [21]:
parties_table.plot(x="State", y=["APC", "PDP"], figsize=(10,25), kind="barh", grid=100)

Out[21]:
<matplotlib.axes._subplots.AxesSubplot at 0xb6d0da0>

Lets see what the bottom states with lowest number of votes have to offer

In [22]:
low_vote_states = vote_sum.sort_values()[:11]
low_vote_states

Out[22]:
HOPE     7435
UDP      9208
KOWA    13076
UPP     18220
AA      22125
NCP     24455
PPN     24475
CPP     36300
ACPN    40311
dtype: int64
In [23]:
low_vote_states.plot(kind="bar", figsize=(15, 5), grid=100)

Out[23]:
<matplotlib.axes._subplots.AxesSubplot at 0xbb76a90>

## HOPE Party¶

Lets see the state that voted most for the lowest rank party - HOPE

In [24]:
hope_party = parties_table[['State', 'HOPE']]
hope_party.plot(x='State', y='HOPE', kind='bar', figsize=(15, 5))

Out[24]:
<matplotlib.axes._subplots.AxesSubplot at 0xc15d1d0>

As seen above, the states that voted most for lowest rank party (HOPE) are Ebonyi, Oyo and Rivers.

# What next?¶

You can do more with this dataset, but for me that is it on analysing Nigeria 2015 presidential election result with python.

Next, I will do a spatial analysis on thesame election result dataset with QGIS (http://qgis.org/) and Tableau (http://tableau.com/). Note that there are excellent python packages that supports spatial analysis, namely: GeoPandas, PySAL, Pyshp, Shapely, ArcPy, PyQGIS, Fiona, Rasterio, GDAL/OGR etc

So if you are interested in the spatial analysis, click on the link below:-