Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 5 : Total votes per year We want to answer the question: what year had the highest voter turnout as a fraction of the

Part 5: Total votes per year
We want to answer the question: what year had the highest voter turnout as a fraction of
the population?
Let's count the votes cast in 2020
Note: Remember that for a dataframe df, we can use
df . loc [ column_index] to select all the rows where column_index is
True. From that, we can use the syntax df . loc [df [ column ]==value ]
to filter for the rows where a given column has a given value.
a. Using this syntax for . loc, create a dataframe which only includes rows
from 2020. This sub-dataframe should have 547 rows.
b. Get the column corresponding to candidate votes and take its sum. That
sum should be the total number of votes cast in 2020.
Calculate the vote totals for each year from 1976 to 2020.
a. You can do this in one line of code with a particular pandas function. Try
to figure out which function it is.
b. If you can't figure it out, use a for loop.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

Where and how are cash dividends reported?

Answered: 1 week ago

Question

' Which areas are you most dependent on to get your work done?

Answered: 1 week ago