{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "         Voter ID   County Candidate\n",
      "0        12864552    Marsh      Khan\n",
      "1        17444633    Marsh    Correy\n",
      "2        19330107    Marsh      Khan\n",
      "3        19865775    Queen      Khan\n",
      "4        11927875    Marsh      Khan\n",
      "5        19014606    Marsh        Li\n",
      "6        17775191    Queen    Correy\n",
      "7        14003692    Marsh      Khan\n",
      "8        14255761    Marsh      Khan\n",
      "9        13870173    Marsh    Correy\n",
      "10       16793141    Marsh      Khan\n",
      "11       10591158    Bamoo    Correy\n",
      "12       12344763  Trandee      Khan\n",
      "13       18611011    Marsh      Khan\n",
      "14       17845903    Marsh    Correy\n",
      "15       12621425  Trandee      Khan\n",
      "16       14365844    Marsh    Correy\n",
      "17       13444989    Marsh    Correy\n",
      "18       19204501  Trandee      Khan\n",
      "19       10098063    Queen    Correy\n",
      "20       19843246    Marsh    Correy\n",
      "21       11509120    Marsh    Correy\n",
      "22       13402499    Marsh    Correy\n",
      "23       18138694    Marsh      Khan\n",
      "24       15056703    Marsh      Khan\n",
      "25       12026178    Queen      Khan\n",
      "26       16667390    Marsh      Khan\n",
      "27       12847422    Queen      Khan\n",
      "28       10599242    Marsh      Khan\n",
      "29       18558857    Queen    Correy\n",
      "...           ...      ...       ...\n",
      "3520971  17923362    Marsh      Khan\n",
      "3520972  11357988    Marsh      Khan\n",
      "3520973  13741548    Marsh    Correy\n",
      "3520974  19929693    Marsh      Khan\n",
      "3520975  16441960    Marsh      Khan\n",
      "3520976  19992954    Marsh  O'Tooley\n",
      "3520977  13845046    Marsh      Khan\n",
      "3520978  18550834    Marsh    Correy\n",
      "3520979  17540334    Queen      Khan\n",
      "3520980  11020483    Queen  O'Tooley\n",
      "3520981  15912885  Trandee      Khan\n",
      "3520982  12609301    Marsh      Khan\n",
      "3520983  14774584    Marsh        Li\n",
      "3520984  13283796    Marsh      Khan\n",
      "3520985  13359648    Bamoo      Khan\n",
      "3520986  17391173    Queen    Correy\n",
      "3520987  18995053    Queen      Khan\n",
      "3520988  11867516    Bamoo        Li\n",
      "3520989  18589143    Marsh      Khan\n",
      "3520990  12282098    Marsh      Khan\n",
      "3520991  16950418    Marsh    Correy\n",
      "3520992  13715415    Marsh      Khan\n",
      "3520993  18129849    Marsh      Khan\n",
      "3520994  15785886    Marsh    Correy\n",
      "3520995  12890090    Marsh    Correy\n",
      "3520996  18050509    Marsh      Khan\n",
      "3520997  13060332    Marsh      Khan\n",
      "3520998  16754708    Queen      Khan\n",
      "3520999  12083146    Queen      Khan\n",
      "3521000  14526187    Queen  O'Tooley\n",
      "\n",
      "[3521001 rows x 3 columns]\n"
     ]
    }
   ],
   "source": [
    "df = pd.read_csv((\"election_data.csv\"),encoding = \"utf-8\",sep =\",\")\n",
    "print(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total Votes: 3521001\n",
      "Queen\n"
     ]
    }
   ],
   "source": [
    "total_votes = 0\n",
    "candidate = set()\n",
    "vote1 = 0\n",
    "vote2 = 0\n",
    "vote3 = 0\n",
    "vote4 = 0\n",
    "\n",
    "for i in range(len(df)):\n",
    "     total_votes = total_votes + 1\n",
    "print(\"Total Votes: {}\".format(total_votes))\n",
    "#      candidate.add(row[2])\n",
    "print(df.iloc[i,1])\n",
    "if df.iloc[i,2] == 'Correy':\n",
    "    vote1 = vote1 + 1\n",
    "elif df.iloc[i,2] == 'Khan':\n",
    "         vote2 = vote2 + 1\n",
    "elif df.iloc[i,2] == 'Li':\n",
    "         vote3 = vote3 + 1\n",
    "elif df.iloc[i,2] == 'O’Tooley':\n",
    "         vote4 = vote4 + 1\n",
    "\n",
    "if total_votes == 'Correy':\n",
    "    print(\"Total Votes: {}\".format(candidate))\n",
    "elif total_votes == 'Khan':\n",
    "    print(\"Total Votes: {}\".format(candidate))\n",
    "elif total_votes == 'Li':\n",
    "    print(\"Total Votes: {}\".format(candidate))\n",
    "elif total_votes == 'O’Tooley':\n",
    "    print(\"Total Votes: {}\".format(candidate))\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<_io.TextIOWrapper name='result.txt' mode='w' encoding='cp1252'>\n"
     ]
    }
   ],
   "source": [
    "f = open (\"result.txt\",\"w\")\n",
    "f.write(\"Analysis\\n\")\n",
    "f.write(\"---------------\\n\")\n",
    "f.write((\"vote1:\" +str(total_votes)) + \"\\n\")\n",
    "f.write(\"vote2:\" + str(total_votes) + \"\\n\")\n",
    "f.write(\"vote3:\" + str(total_votes) + \"\\n\")\n",
    "f.write(\"vote4:\" + str(total_votes) + \"\\n\")\n",
    "f.close()\n",
    "print(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
