Election Results Dashboard Documentation

Published on: August 17, 2025


The Election Results Dashboard is a powerful, data-driven tool that enables users to explore the Indian Parliamentary Election results for 2024. While the official Election Commission of India (ECI) website provides raw textual data and basic results, this dashboard offers enhanced features, more interactive visualizations, and detailed constituency-level analysis.

Missing Functionality in the Official ECI Website:

  1. Detailed Constituency Breakdown: The official ECI website provides only basic information about the winner, but lacks a deep breakdown of vote shares, margins, or NOTA (None of the Above) details.
  2. State-wise Party Performance: The ECI site lacks a consolidated view of party-wise performance at the state level, making it difficult to compare results across regions.
  3. Visualization Tools: There is no easy-to-use visualization interface in the official website; users cannot interactively explore vote share by party, candidate, or state.

Key Features of the Dashboard:

  • Interactive Filters: Allows users to filter data by State, Party, Constituency, and more.
  • State-wise Analysis: Visualizations of seats won by each party in each state.
  • Constituency-level Results: Detailed breakdown of results for individual constituencies, including candidates, party affiliations, votes, and statuses.
  • Vote Distribution Charts: Visuals showing vote distribution among candidates and parties.
  • Party-wise Vote Share: Pie chart for easy understanding of the vote share by party across constituencies.

Installation and Setup

Setting Up the Project

Follow these steps to set up the project on your machine:

  1. Clone the repository:

    BASH
    git clone https://github.com/cln35h0/electionresult.git
    
    cd electionresult
    
  2. Install required dependencies: Install the necessary Python libraries by running:

    BASH
    pip install -r requirements.txt
    
  3. Run the application: Launch the Streamlit app to visualize the data:

    BASH
    streamlit run streamlit_app.py
    

This will launch a local server and open the Election Results Dashboard in your browser.


Data Collection

The data for the Election Results Dashboard is scraped directly from the official Election Commission of India (ECI) website. This data includes:

  1. Textual Election Results for each constituency.
  2. Screenshots of the result pages, preserving the visual layout of the official site.

Scraping Data with scrapper.py

The scrapper.py script automates the process of extracting election data:

  • Full-page screenshots are captured using Chrome’s DevTools Protocol (CDP), ensuring we get an accurate visual representation of the ECI pages.
  • Textual content from each constituency’s results page is scraped and saved as .txt files.
  • Results for all constituencies across all states and Union Territories (UTs) are gathered.

Data Processing with extract.py

Once the raw data is scraped, the extract.py script performs the following operations:

  • Extracts key information: Constituency names, candidate names, party affiliations, votes, and winner/loser status.
  • Maps state codes to full state names for easy reference.
  • Cleans and structures the data: Filters out incomplete or irrelevant information (such as empty rows or non-numeric vote counts).
  • Stores the data in a CSV format, which can easily be loaded and visualized.

Data Visualization

The Election Results Dashboard uses Streamlit for the user interface and Plotly Express for interactive charts.

Types of Visualizations:

Here’s a more detailed version of the Types of Visualizations for your documentation:


Types of Visualizations:

  1. Top Candidates by Votes: 📊

    Description: This visualization highlights the top 10 candidates who received the most votes in the selected state or across all constituencies. The candidates are plotted on the X-axis, and their vote count is represented on the Y-axis.

    • Purpose: Helps users quickly identify the top political figures and provides insight into the candidates' popularity. It also uses color coding based on the political party to easily distinguish between different parties.
    • Interactive Feature: Users can hover over each bar to see the exact number of votes each candidate received.
  2. Party-wise Total Votes: 🍰

    Description: This pie chart displays the percentage of total votes each party has received across the entire election. Each slice represents a political party, and its size is proportional to the total votes the party accumulated.

    • Purpose: Gives a quick overview of the election's overall outcome by showcasing each party’s share of the vote. It enables users to visualize which party had the largest support base at a glance.
    • Interactive Feature: Users can hover over the chart slices to see the exact number of votes and the percentage share for each party.
  3. State-wise Constituency Wins: 📊

    Description: This visualization shows the number of constituencies won by each party in every state/UT. The X-axis represents the states/UTs, while the Y-axis shows the number of constituencies each party won within those regions.

    • Purpose: Provides an at-a-glance view of how each party performed across various states and union territories. It helps users identify regions where a party had a stronghold or a dominating presence.
    • Interactive Feature: Hovering over the bars displays the exact count of constituencies won by each party in the respective state/UT.
  4. Vote Distribution in Constituency: 📊

    Description: For each selected constituency, this bar chart displays the vote distribution among all candidates, with candidates' names on the X-axis and their respective vote counts on the Y-axis. The bars are color-coded based on the party affiliation of the candidates.

    • Purpose: Allows users to compare the vote counts of each candidate within a specific constituency. This helps to understand the competition between candidates and provides insights into vote margins and party performance in that region.
    • Interactive Feature: Hovering over each bar shows the exact number of votes, candidate name, and party.
  5. Detailed Candidate-wise Results:

    Description: A comprehensive table that lists detailed election results for each candidate, including their name, party affiliation, total votes, and whether they won or lost the election in the selected constituency. This table can be filtered based on the state/UT and constituency.

    • Purpose: Provides a detailed and structured overview of the election results for each candidate, including their vote share, status (won/lost), and party affiliation. It allows users to drill down into individual candidates' performance.
    • Interactive Feature: Users can filter the data based on state/UT or party and can sort the results by votes or candidate names for easier analysis.

How to Use

Scraping Election Data

To start collecting the election data, simply run:

PYTHON
python scrapper.py

This will:

  • Download all relevant result pages and screenshots from the official ECI site.
  • Save the data in a structured folder hierarchy:
    • saved_pages (for text files)
    • screenshots (for screenshots)
    • logs (for any scraping-related issues).

Processing the Data

After scraping the data, process it to make it ready for analysis:

PYTHON
python extract.py

This will:

  • Parse the scraped text files.
  • Extract relevant data: Constituency number, party names, candidate names, votes, and results.
  • Clean the data and save it as a CSV file results.csv, ready for visualization.

Running the Dashboard

To view and explore the election results visually, use Streamlit:

BASH
streamlit run streamlit_app.py

This will start the Election Results Dashboard in your web browser. The dashboard allows you to filter and view results by State, Party, and Constituency.


Features

1. Dashboard View

The dashboard provides an interactive view of the overall election results. Key features include:

  • State-wise Seats Won: A bar chart showing the number of seats each party won in each state.
  • Vote Share by Party: A pie chart visualizing the total vote share for each party.
  • Top Candidates: A bar chart of the top 10 candidates by votes.

2. Constituency Analysis

Users can select a specific State and Constituency to view detailed results, such as:

  • Winner: The candidate who received the highest votes in that constituency.
  • Runner-up: The second-highest vote-getter.
  • NOTA: Information on votes for "None of the Above".
  • Vote Distribution: A bar chart displaying the vote distribution among all candidates.

3. Interactive Filters

  • State/UT: Filter results by State or Union Territory (UT).
  • Party: View results specific to a particular party.
  • Constituency: Select a constituency and analyze its results.

Conclusion

This Election Results Dashboard provides a richer, interactive, and more insightful analysis of the Indian parliamentary election results than the official ECI website. By visualizing party-wise vote shares, constituency-level results, and more, it makes it easy to explore the election data and understand the overall political landscape.

Whether you’re a researcher, journalist, or simply an interested citizen, this dashboard offers an intuitive and comprehensive way to interact with election results.

If you encounter any issues, please send an email regarding them to journal.cln35h@gmail.com.