{"id":37667859,"url":"https://github.com/albertov5/tec-data-03-python","last_synced_at":"2026-01-16T12:00:44.276Z","repository":{"id":46869152,"uuid":"513765208","full_name":"AlbertoV5/tec-data-03-python","owner":"AlbertoV5","description":"Data Analytics Bootcamp","archived":false,"fork":false,"pushed_at":"2022-07-22T03:32:53.000Z","size":1842,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-03-04T18:11:45.837Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlbertoV5.png","metadata":{"files":{"readme":"readme.html","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-14T05:00:31.000Z","updated_at":"2022-07-14T05:35:29.000Z","dependencies_parsed_at":"2022-09-23T07:21:20.990Z","dependency_job_id":null,"html_url":"https://github.com/AlbertoV5/tec-data-03-python","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/AlbertoV5/tec-data-03-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlbertoV5%2Ftec-data-03-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlbertoV5%2Ftec-data-03-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlbertoV5%2Ftec-data-03-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlbertoV5%2Ftec-data-03-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlbertoV5","download_url":"https://codeload.github.com/AlbertoV5/tec-data-03-python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlbertoV5%2Ftec-data-03-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-16T12:00:26.223Z","updated_at":"2026-01-16T12:00:44.209Z","avatar_url":"https://github.com/AlbertoV5.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003c!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"\u003e\n\u003chtml xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\"\u003e\n\u003chead\u003e\n\u003c!-- 2022-07-21 Thu 22:30 --\u003e\n\u003cmeta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" /\u003e\n\u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /\u003e\n\u003ctitle\u003eWeek 3 Challenge\u003c/title\u003e\n\u003cmeta name=\"author\" content=\"Alberto Valdez\" /\u003e\n\u003cmeta name=\"generator\" content=\"Org Mode\" /\u003e\n\u003clink rel=\"stylesheet\" type=\"text/css\" href=\"https://albertov5.github.io/org-html-themes/src/readtheorg_theme/css/htmlize.css\"/\u003e\n\u003clink rel=\"stylesheet\" type=\"text/css\" href=\"https://albertov5.github.io/org-html-themes/src/readtheorg_theme/css/readtheorg.css\"/\u003e\n\u003cscript src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js\"\u003e\u003c/script\u003e\n\u003cscript type=\"text/javascript\" src=\"https://albertov5.github.io/org-html-themes/src/lib/js/jquery.stickytableheaders.min.js\"\u003e\u003c/script\u003e\n\u003cscript type=\"text/javascript\" src=\"https://albertov5.github.io/org-html-themes/src/readtheorg_theme/js/readtheorg.js\"\u003e\u003c/script\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003cdiv id=\"content\" class=\"content\"\u003e\n\u003ch1 class=\"title\"\u003eWeek 3 Challenge\u003c/h1\u003e\n\u003cdiv id=\"table-of-contents\" role=\"doc-toc\"\u003e\n\u003ch2\u003eTable of Contents\u003c/h2\u003e\n\u003cdiv id=\"text-table-of-contents\" role=\"doc-toc\"\u003e\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"#org25e72be\"\u003e1. PyPoll Election Audit\u003c/a\u003e\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"#org677721d\"\u003e1.1. Resources\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"#org6460e9e\"\u003e1.2. Election Audit Results\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"#orgc6a08af\"\u003e1.3. Summary of the Python Problem\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"#org09e80de\"\u003e1.4. Closing Thoughts\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003e\n\u003ca href=\"https://github.com/AlbertoV5/tec-data-03-python\"\u003eRepository\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cdiv id=\"outline-container-org25e72be\" class=\"outline-2\"\u003e\n\u003ch2 id=\"org25e72be\"\u003e\u003cspan class=\"section-number-2\"\u003e1.\u003c/span\u003e PyPoll Election Audit\u003c/h2\u003e\n\u003cdiv class=\"outline-text-2\" id=\"text-1\"\u003e\n\u003cp\u003e\nIn this project, we were given the task to find the results of an election by counting the votes in a large dataset. We were also looking for the following data:\n\u003c/p\u003e\n\n\u003col class=\"org-ol\"\u003e\n\u003cli\u003eTotal number of votes.\u003c/li\u003e\n\u003cli\u003eList of candidates who received votes.\u003c/li\u003e\n\u003cli\u003eNumber of votes per candidate and their percentage.\u003c/li\u003e\n\u003cli\u003eList of counties that had vote turnouts.\u003c/li\u003e\n\u003cli\u003eCounty with the largest amount of vote turnouts.\u003c/li\u003e\n\u003c/ol\u003e\n\n\u003cp\u003e\nWe designed an algorithm that would do the work for us by feeding it a csv file and storing the results in a text file.\n\u003c/p\u003e\n\u003c/div\u003e\n\n\u003cdiv id=\"outline-container-org677721d\" class=\"outline-3\"\u003e\n\u003ch3 id=\"org677721d\"\u003e\u003cspan class=\"section-number-3\"\u003e1.1.\u003c/span\u003e Resources\u003c/h3\u003e\n\u003cdiv class=\"outline-text-3\" id=\"text-1-1\"\u003e\n\u003cp\u003e\nPython version: \u003ccode\u003ePython 3.7.13\u003c/code\u003e VS Code version: \u003ccode\u003e1.69.2\u003c/code\u003e.\n\u003c/p\u003e\n\n\u003cp\u003e\nDataset: \u003ccode\u003eelection_results.csv\u003c/code\u003e.\n\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\n\u003cdiv id=\"outline-container-org6460e9e\" class=\"outline-3\"\u003e\n\u003ch3 id=\"org6460e9e\"\u003e\u003cspan class=\"section-number-3\"\u003e1.2.\u003c/span\u003e Election Audit Results\u003c/h3\u003e\n\u003cdiv class=\"outline-text-3\" id=\"text-1-2\"\u003e\n\u003cp\u003e\nWe found out that the there were \u003ccode\u003e369,711\u003c/code\u003e votes registered, from which \u003ccode\u003e82.8%\u003c/code\u003e came from Denver, the rest came from Jefferson \u003ccode\u003e(10.5%)\u003c/code\u003e and Arapahoe \u003ccode\u003e(6.7%)\u003c/code\u003e.\n\u003c/p\u003e\n\n\u003cp\u003e\nThe winner of the election was \u003ccode\u003eDiana DeGetter\u003c/code\u003e with \u003ccode\u003e73.8%\u003c/code\u003e of the vote. These are the rest of the results:\n\u003c/p\u003e\n\n\u003ctable border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\"\u003e\n\n\n\u003ccolgroup\u003e\n\u003ccol  class=\"org-left\" /\u003e\n\n\u003ccol  class=\"org-left\" /\u003e\n\n\u003ccol  class=\"org-right\" /\u003e\n\u003c/colgroup\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth scope=\"col\" class=\"org-left\"\u003eCandidate\u003c/th\u003e\n\u003cth scope=\"col\" class=\"org-left\"\u003eVotes\u003c/th\u003e\n\u003cth scope=\"col\" class=\"org-right\"\u003ePercentage\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd class=\"org-left\"\u003eRaymond Anthony Doane\u003c/td\u003e\n\u003ctd class=\"org-left\"\u003e11,606\u003c/td\u003e\n\u003ctd class=\"org-right\"\u003e3.1%\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd class=\"org-left\"\u003eCharles Casper Stockham\u003c/td\u003e\n\u003ctd class=\"org-left\"\u003e85,212\u003c/td\u003e\n\u003ctd class=\"org-right\"\u003e23.0%\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd class=\"org-left\"\u003eDiana DeGette\u003c/td\u003e\n\u003ctd class=\"org-left\"\u003e272,892\u003c/td\u003e\n\u003ctd class=\"org-right\"\u003e73.8%\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003cp\u003e\nThe following data was stored to the \u003ccode\u003eelection_analysis.txt\u003c/code\u003e file.\n\u003c/p\u003e\n\n\u003cdiv class=\"org-src-container\"\u003e\n\u003cpre class=\"src src-shell\"\u003e\u003cspan style=\"color: #35CDAF;\"\u003ecat\u003c/span\u003e election_analysis.txt\n\u003c/pre\u003e\n\u003c/div\u003e\n\n\u003cpre class=\"example\" id=\"org5c801f0\"\u003e\n\nElection Results\n-------------------------\nTotal Votes: 369,711\n-------------------------\n\nCounty Votes:\nJefferson: 10.5% (38,855)\nDenver: 82.8% (306,055)\nArapahoe: 6.7% (24,801)\n\n-------------------------\nLargest County Turnout: Denver\n-------------------------\nCharles Casper Stockham: 23.0% (85,213)\nDiana DeGette: 73.8% (272,892)\nRaymon Anthony Doane: 3.1% (11,606)\n-------------------------\nWinner: Diana DeGette\nWinning Vote Count: 272,892\nWinning Percentage: 73.8%\n-------------------------\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\n\n\u003cdiv id=\"outline-container-orgc6a08af\" class=\"outline-3\"\u003e\n\u003ch3 id=\"orgc6a08af\"\u003e\u003cspan class=\"section-number-3\"\u003e1.3.\u003c/span\u003e Summary of the Python Problem\u003c/h3\u003e\n\u003cdiv class=\"outline-text-3\" id=\"text-1-3\"\u003e\n\u003cp\u003e\nThe following is a partial description of how to solve the problem using Python.\n\u003c/p\u003e\n\n\u003cp\u003e\nImporting the libraries and loading the data.\n\u003c/p\u003e\n\u003cdiv class=\"org-src-container\"\u003e\n\u003cpre class=\"src src-python\"\u003e\u003cspan style=\"color: #339CDB;\"\u003eimport\u003c/span\u003e csv\n\u003cspan style=\"color: #339CDB;\"\u003efrom\u003c/span\u003e pathlib \u003cspan style=\"color: #339CDB;\"\u003eimport\u003c/span\u003e Path\n\n\u003cspan style=\"color: #a9dbfa;\"\u003eresources\u003c/span\u003e = Path.cwd() / \u003cspan style=\"color: #c5937c;\"\u003e\"resources\"\u003c/span\u003e\n\u003cspan style=\"color: #a9dbfa;\"\u003efile_to_load\u003c/span\u003e = resources / \u003cspan style=\"color: #c5937c;\"\u003e\"election_results.csv\"\u003c/span\u003e\n\u003cspan style=\"color: #a9dbfa;\"\u003efile_to_save\u003c/span\u003e = Path.cwd() / \u003cspan style=\"color: #c5937c;\"\u003e\"election_analysis.txt\"\u003c/span\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\n\u003cp\u003e\nInitializing variables.\n\u003c/p\u003e\n\u003cdiv class=\"org-src-container\"\u003e\n\u003cpre class=\"src src-python\"\u003e\u003cspan style=\"color: #a9dbfa;\"\u003ecandidate_list\u003c/span\u003e = []\n\u003cspan style=\"color: #a9dbfa;\"\u003ecounty_list\u003c/span\u003e = []\n\u003cspan style=\"color: #a9dbfa;\"\u003ecandidate_votes\u003c/span\u003e = {}\n\u003cspan style=\"color: #a9dbfa;\"\u003ecounty_votes\u003c/span\u003e = {}\n\u003c/pre\u003e\n\u003c/div\u003e\n\n\u003cp\u003e\nThe most important part of the code was that we were able to check if the candidate name existed already in the dictionary, and if it didn\u0026rsquo;t we would add it to the list only once and move on into just incrementing the vote count.\n\u003c/p\u003e\n\n\u003cp\u003e\nThis is a reduced example of the process.\n\u003c/p\u003e\n\u003cdiv class=\"org-src-container\"\u003e\n\u003cpre class=\"src src-python\"\u003e\u003cspan style=\"color: #339CDB;\"\u003ewith\u003c/span\u003e \u003cspan style=\"color: #C586C0;\"\u003eopen\u003c/span\u003e(file_to_load) \u003cspan style=\"color: #339CDB;\"\u003eas\u003c/span\u003e \u003cspan style=\"color: #a9dbfa;\"\u003eelection_data\u003c/span\u003e:\n    reader = csv.reader(election_data)\n    \u003cspan style=\"color: #a9dbfa;\"\u003eheader\u003c/span\u003e = \u003cspan style=\"color: #C586C0;\"\u003enext\u003c/span\u003e(reader)\n    \u003cspan style=\"color: #339CDB;\"\u003efor\u003c/span\u003e row \u003cspan style=\"color: #339CDB;\"\u003ein\u003c/span\u003e \u003cspan style=\"color: #a9dbfa;\"\u003ereader\u003c/span\u003e:\n        candidate_name = row[\u003cspan style=\"color: #B5CEA8; font-weight: bold;\"\u003e2\u003c/span\u003e]\n        \u003cspan style=\"color: #a9dbfa;\"\u003ecounty_name\u003c/span\u003e = row[\u003cspan style=\"color: #B5CEA8; font-weight: bold;\"\u003e1\u003c/span\u003e]\n        \u003cspan style=\"color: #579C4C;\"\u003e# \u003c/span\u003e\u003cspan style=\"color: #579C4C;\"\u003eCheck for candidate\u003c/span\u003e\n        \u003cspan style=\"color: #339CDB;\"\u003eif\u003c/span\u003e candidate_name \u003cspan style=\"color: #339CDB;\"\u003enot\u003c/span\u003e \u003cspan style=\"color: #339CDB;\"\u003ein\u003c/span\u003e \u003cspan style=\"color: #a9dbfa;\"\u003ecandidate_list\u003c/span\u003e:\n            candidate_list.append(candidate_name)\n            candidate_votes[\u003cspan style=\"color: #a9dbfa;\"\u003ecandidate_name\u003c/span\u003e] = \u003cspan style=\"color: #B5CEA8; font-weight: bold;\"\u003e0\u003c/span\u003e\n        \u003cspan style=\"color: #a9dbfa;\"\u003ecandidate_votes\u003c/span\u003e[\u003cspan style=\"color: #a9dbfa;\"\u003ecandidate_name\u003c/span\u003e] += \u003cspan style=\"color: #B5CEA8; font-weight: bold;\"\u003e1\u003c/span\u003e\n        \u003cspan style=\"color: #579C4C;\"\u003e# \u003c/span\u003e\u003cspan style=\"color: #579C4C;\"\u003eCheck for county\u003c/span\u003e\n        \u003cspan style=\"color: #339CDB;\"\u003eif\u003c/span\u003e county_name \u003cspan style=\"color: #339CDB;\"\u003enot\u003c/span\u003e \u003cspan style=\"color: #339CDB;\"\u003ein\u003c/span\u003e \u003cspan style=\"color: #a9dbfa;\"\u003ecounty_list\u003c/span\u003e:\n            county_list.append(county_name)\n            county_votes[\u003cspan style=\"color: #a9dbfa;\"\u003ecounty_name\u003c/span\u003e] = \u003cspan style=\"color: #B5CEA8; font-weight: bold;\"\u003e0\u003c/span\u003e\n        \u003cspan style=\"color: #a9dbfa;\"\u003ecounty_votes\u003c/span\u003e[\u003cspan style=\"color: #a9dbfa;\"\u003ecounty_name\u003c/span\u003e] += \u003cspan style=\"color: #B5CEA8; font-weight: bold;\"\u003e1\u003c/span\u003e\n\n\u003cspan style=\"color: #C586C0;\"\u003eprint\u003c/span\u003e(candidate_votes)\n\u003cspan style=\"color: #C586C0;\"\u003eprint\u003c/span\u003e(county_votes)\n\u003c/pre\u003e\n\u003c/div\u003e\n\n\u003cdiv class=\"org-src-container\"\u003e\n\u003cpre class=\"src src-org\"\u003e{'Charles Casper Stockham': 85213, 'Diana DeGette': 272892, 'Raymon Anthony Doane': 11606}\n{'Jefferson': 38855, 'Denver': 306055, 'Arapahoe': 24801}\n\u003c/pre\u003e\n\u003c/div\u003e\n\n\u003cp\u003e\nThen after that storing the results was a simple process as we can do whatever we want with the data stored in the dictionaries.\n\u003c/p\u003e\n\n\u003cp\u003e\nFor example, printing the total votes or percentage of values from any key. As well as making sure that the totals match.\n\u003c/p\u003e\n\u003cdiv class=\"org-src-container\"\u003e\n\u003cpre class=\"src src-python\"\u003e\u003cspan style=\"color: #a9dbfa;\"\u003etotal_votes_candidate\u003c/span\u003e = \u003cspan style=\"color: #C586C0;\"\u003esum\u003c/span\u003e(candidate_votes.values())\n\u003cspan style=\"color: #a9dbfa;\"\u003etotal_votes_county\u003c/span\u003e = \u003cspan style=\"color: #C586C0;\"\u003esum\u003c/span\u003e(county_votes.values())\n\u003cspan style=\"color: #339CDB;\"\u003eassert\u003c/span\u003e total_votes_candidate == total_votes_county\n\u003cspan style=\"color: #C586C0;\"\u003eprint\u003c/span\u003e(f\u003cspan style=\"color: #c5937c;\"\u003e\"Total Votes: \u003c/span\u003e{total_votes_candidate}\u003cspan style=\"color: #c5937c;\"\u003e\"\u003c/span\u003e)\n\u003cspan style=\"color: #C586C0;\"\u003eprint\u003c/span\u003e(\u003cspan style=\"color: #c5937c;\"\u003e\"Percentage for Diana DeGette:\"\u003c/span\u003e)\n\u003cspan style=\"color: #C586C0;\"\u003eprint\u003c/span\u003e(f\u003cspan style=\"color: #c5937c;\"\u003e\"\u003c/span\u003e{100 * candidate_votes['Diana DeGette'] / total_votes_candidate:.2f}\u003cspan style=\"color: #c5937c;\"\u003e%\"\u003c/span\u003e)\n\u003c/pre\u003e\n\u003c/div\u003e\n\n\u003cdiv class=\"org-src-container\"\u003e\n\u003cpre class=\"src src-org\"\u003eTotal Votes: 369711\nPercentage for Diana DeGette:\n73.81%\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\n\n\u003cdiv id=\"outline-container-org09e80de\" class=\"outline-3\"\u003e\n\u003ch3 id=\"org09e80de\"\u003e\u003cspan class=\"section-number-3\"\u003e1.4.\u003c/span\u003e Closing Thoughts\u003c/h3\u003e\n\u003cdiv class=\"outline-text-3\" id=\"text-1-4\"\u003e\n\u003cp\u003e\nPython does a great job on removing a lot of obstacles in between us as the users and the computer, as it\u0026rsquo;s really easy to generate working code starting from a solid pseudocode / algorithm. Even if it\u0026rsquo;s not the fastest in processing the data, it\u0026rsquo;s definitely the tool that can get the job done in the least amount of time once you learn it.\n\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"postamble\" class=\"status\"\u003e\n\u003cp class=\"author\"\u003eAuthor: Alberto Valdez\u003c/p\u003e\n\u003cp class=\"date\"\u003eCreated: 2022-07-21 Thu 22:30\u003c/p\u003e\n\u003c/div\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbertov5%2Ftec-data-03-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falbertov5%2Ftec-data-03-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbertov5%2Ftec-data-03-python/lists"}