2024 Federal Election Polling Data

Suraj Rampure

In [1]:
from datascience import *
import numpy as np
Table.interactive_plots()
In [2]:
pres = Table.read_table('data/president_primary_polls.csv')
In [3]:
pres
Out[3]:
question_id poll_id race_id cycle state pollster_id pollster sponsor_ids sponsors display_name pollster_rating_id pollster_rating_name fte_grade sample_size population population_full methodology office_type start_date end_date sponsor_candidate internal partisan tracking nationwide_batch created_at notes url stage party answer candidate_id candidate_name pct
140650 74665 8915 2024 nan 294 McLaughlin & Associates nan nan McLaughlin & Associates 203 McLaughlin & Associates C/D 458 lv lv-d Online U.S. President 4/8/21 4/13/21 nan False nan False False 4/16/21 12:55 nan https://mclaughlinonline.com/pols/wp-content/uploads/202 ... primary DEM Harris 16661 Kamala D. Harris 34
140650 74665 8915 2024 nan 294 McLaughlin & Associates nan nan McLaughlin & Associates 203 McLaughlin & Associates C/D 458 lv lv-d Online U.S. President 4/8/21 4/13/21 nan False nan False False 4/16/21 12:55 nan https://mclaughlinonline.com/pols/wp-content/uploads/202 ... primary DEM Obama 16660 Michelle Obama 20
140650 74665 8915 2024 nan 294 McLaughlin & Associates nan nan McLaughlin & Associates 203 McLaughlin & Associates C/D 458 lv lv-d Online U.S. President 4/8/21 4/13/21 nan False nan False False 4/16/21 12:55 nan https://mclaughlinonline.com/pols/wp-content/uploads/202 ... primary DEM Buttigieg 16662 Pete Buttigieg 5
140650 74665 8915 2024 nan 294 McLaughlin & Associates nan nan McLaughlin & Associates 203 McLaughlin & Associates C/D 458 lv lv-d Online U.S. President 4/8/21 4/13/21 nan False nan False False 4/16/21 12:55 nan https://mclaughlinonline.com/pols/wp-content/uploads/202 ... primary DEM Ocasio-Cortez 16664 Alexandria Ocasio-Cortez 3
140650 74665 8915 2024 nan 294 McLaughlin & Associates nan nan McLaughlin & Associates 203 McLaughlin & Associates C/D 458 lv lv-d Online U.S. President 4/8/21 4/13/21 nan False nan False False 4/16/21 12:55 nan https://mclaughlinonline.com/pols/wp-content/uploads/202 ... primary DEM Cuomo 16663 Andrew Cuomo 2
140650 74665 8915 2024 nan 294 McLaughlin & Associates nan nan McLaughlin & Associates 203 McLaughlin & Associates C/D 458 lv lv-d Online U.S. President 4/8/21 4/13/21 nan False nan False False 4/16/21 12:55 nan https://mclaughlinonline.com/pols/wp-content/uploads/202 ... primary DEM Booker 16666 Cory A. Booker 4
140650 74665 8915 2024 nan 294 McLaughlin & Associates nan nan McLaughlin & Associates 203 McLaughlin & Associates C/D 458 lv lv-d Online U.S. President 4/8/21 4/13/21 nan False nan False False 4/16/21 12:55 nan https://mclaughlinonline.com/pols/wp-content/uploads/202 ... primary DEM Klobuchar 16671 Amy Klobuchar 4
140650 74665 8915 2024 nan 294 McLaughlin & Associates nan nan McLaughlin & Associates 203 McLaughlin & Associates C/D 458 lv lv-d Online U.S. President 4/8/21 4/13/21 nan False nan False False 4/16/21 12:55 nan https://mclaughlinonline.com/pols/wp-content/uploads/202 ... primary DEM Hickenlooper 16665 John Wright Hickenlooper 2
140650 74665 8915 2024 nan 294 McLaughlin & Associates nan nan McLaughlin & Associates 203 McLaughlin & Associates C/D 458 lv lv-d Online U.S. President 4/8/21 4/13/21 nan False nan False False 4/16/21 12:55 nan https://mclaughlinonline.com/pols/wp-content/uploads/202 ... primary DEM Patrick 16669 Deval Patrick 1
140650 74665 8915 2024 nan 294 McLaughlin & Associates nan nan McLaughlin & Associates 203 McLaughlin & Associates C/D 458 lv lv-d Online U.S. President 4/8/21 4/13/21 nan False nan False False 4/16/21 12:55 nan https://mclaughlinonline.com/pols/wp-content/uploads/202 ... primary DEM Gillibrand 16667 Kirsten E. Gillibrand 2

... (565 rows omitted)

In [4]:
pres.group('pollster')
Out[4]:
pollster count
Echelon Insights 65
Fabrizio, Lee & Associates 35
Harris Insights & Analytics 13
L├ęger 113
McLaughlin & Associates 182
Morning Consult 41
PEM Management Corporation 7
Praecones Analytica 19
RMG Research 10
Remington Research Group 3

... (3 rows omitted)

In [5]:
# Selecting only relevant rows and columns
pres = pres.where('pollster', 'McLaughlin & Associates') \
           .select('start_date', 'end_date', 'party', 'candidate_name', 'pct')

pres
Out[5]:
start_date end_date party candidate_name pct
4/8/21 4/13/21 DEM Kamala D. Harris 34
4/8/21 4/13/21 DEM Michelle Obama 20
4/8/21 4/13/21 DEM Pete Buttigieg 5
4/8/21 4/13/21 DEM Alexandria Ocasio-Cortez 3
4/8/21 4/13/21 DEM Andrew Cuomo 2
4/8/21 4/13/21 DEM Cory A. Booker 4
4/8/21 4/13/21 DEM Amy Klobuchar 4
4/8/21 4/13/21 DEM John Wright Hickenlooper 2
4/8/21 4/13/21 DEM Deval Patrick 1
4/8/21 4/13/21 DEM Kirsten E. Gillibrand 2

... (172 rows omitted)

In [6]:
pres.where('party', 'DEM') \
    .pivot('start_date', 'candidate_name', 'pct', sum) \
    .select('candidate_name', '12/9/20', '2/24/21', '4/8/21') \
    .sort('4/8/21', descending = True) \
    .barh('candidate_name', 
          title = '2024 Democratic Primary Polls (McLaughlin & Associates)',
          xaxis_title = '%',
          yaxis_title = 'Candidate',
          width = 950, height = 700)