Impact of Social Media Ad Spending on 2024 Indian Elections

Frame 14 4 1 Explore and Read Our Blogs Written By Our Insutry Experts Learn From KSR Data Vizon

Introduction:

The 2024 Indian elections witnessed significant ad spending on social media platforms like Facebook and Instagram by major political parties, particularly BJP and INC. This article delves into the ad spending patterns across different states and analyzes how this spending influenced voter turnout and voting patterns.

Dataset Overview: The dataset comprises three files:

  1. Advertisers Dataset: Insights into the ad spending by various pages (political parties).
  2. Locations Dataset: Details of ad spending across different locations.
  3. Results Dataset: Voting data, including voter turnout and vote counts.

Data Cleaning and Preprocessing:

We began by loading and cleaning the datasets. Missing values were handled appropriately, ensuring the data was ready for analysis. Descriptive statistics provided an overview of the data, laying the foundation for further exploration.

Analysis and Insights:

  1. Ad Spending by Party: The total ad spending by each party was analyzed. The BJP emerged as the highest spender, followed by INC and other regional parties. The visualization highlights the significant financial resources allocated to social media campaigns.
  2. Ad Spending by State: Analyzing the ad spending across states revealed interesting patterns. States like Uttar Pradesh, Maharashtra, and West Bengal saw substantial ad investments, indicating their strategic importance in the elections.
  3. Ad Spending vs. Voter Turnout: We explored the relationship between ad spending and voter turnout. The scatter plot showed a positive correlation, suggesting that higher ad spending might be associated with increased voter turnout in some states.
  4. Correlation Analysis: The correlation matrix provided deeper insights into the relationships between ad spending, voter turnout, and votes. A strong correlation between ad spending and voter turnout was observed, emphasizing the potential impact of targeted ad campaigns.

Advanced Analysis:

A regression analysis was performed to predict voter turnout based on ad spending. The results indicated that ad spending is a significant predictor of voter turnout, reinforcing the importance of financial investments in election campaigns.

Findings and Insights:

Our analysis revealed that strategic ad spending plays a crucial role in influencing voter behavior. Political parties that invested heavily in social media campaigns saw a positive impact on voter turnout. This underscores the evolving dynamics of electioneering in the digital age.

Conclusion:

The 2024 Indian elections highlighted the growing importance of social media in political campaigns. Our analysis demonstrates that targeted ad spending can significantly influence voter turnout and election outcomes. Political parties must continue to adapt to these changing dynamics to effectively engage with the electorate.

Source File

Python Code for the Above Analysis:
Step 1: Extract and Load Data
First, unzip the dataset and load the data into Python.

 1. import zipfile
 2. import pandas as pd
 3.  
 4. # Define the path to the uploaded zip file
 5. zip_file_path = '/mnt/data/elections-data.zip'
 6.  
 7. # Extract the zip file
 8. with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
 9.     zip_ref.extractall('/mnt/data/')
10.  
11. # Load the datasets
12. advertisers_df = pd.read_csv('/mnt/data/advertisers.csv')
13. locations_df = pd.read_csv('/mnt/data/locations.csv')
14. results_df = pd.read_csv('/mnt/data/results.csv')
15.  
16. # Display the first few rows of each dataset
17. advertisers_df.head(), locations_df.head(), results_df.head()
18.  

Step 2: Data Cleaning
Clean and preprocess the data as necessary.

 1. # Check for missing values
 2. advertisers_df.isnull().sum()
 3. locations_df.isnull().sum()
 4. results_df.isnull().sum()
 5.  
 6. # Fill or drop missing values as needed
 7. advertisers_df.fillna(0, inplace=True)
 8. locations_df.fillna(0, inplace=True)
 9. results_df.fillna(0, inplace=True)
10.  

Step 3: Descriptive Statistics and Data Overview
Generate descriptive statistics and an overview of the datasets.

1. # Descriptive statistics for advertisers dataset
2. advertisers_df.describe()
3.  
4. # Descriptive statistics for locations dataset
5. locations_df.describe()
6.  
7. # Descriptive statistics for results dataset
8. results_df.describe()
9.  

Step 4: Analysis
Perform the analysis to understand ad spending and its impact on voting patterns.

  1. Ad Spending by Party
    Analyze and visualize the total ad spending by each party.
 1. import matplotlib.pyplot as plt
 2. import seaborn as sns
 3.  
 4. # Total ad spending by party
 5. total_spending_by_party = advertisers_df.groupby('Party')  ['Spending'].sum().sort_values(ascending=False)
 6.  
 7. # Plot total spending by party
 8. plt.figure(figsize=(12, 8))
 9. sns.barplot(x=total_spending_by_party.index, y=total_spending_by_party.values, palette='viridis')
10. plt.title('Total Ad Spending by Party')
11. plt.xlabel('Party')
12. plt.ylabel('Total Spending (in INR)')
13. plt.xticks(rotation=45)
14. plt.show()
15.  
  1. Ad Spending by State
    Analyze and visualize the total ad spending in each state.
 1. # Total ad spending by state
 2. total_spending_by_state = locations_df.groupby('State')['Spending'].sum().sort_values(ascending=False)
 3.  
 4. # Plot total spending by state
 5. plt.figure(figsize=(14, 10))
 6. sns.barplot(x=total_spending_by_state.index, y=total_spending_by_state.values, palette='viridis')
 7. plt.title('Total Ad Spending by State')
 8. plt.xlabel('State')
 9. plt.ylabel('Total Spending (in INR)')
10. plt.xticks(rotation=90)
11. plt.show()
12.  
  1. Ad Spending vs. Voter Turnout
    Analyze the relationship between ad spending and voter turnout.
 1. # Merge results and locations dataframes to analyze impact on voter turnout
 2. merged_df = pd.merge(results_df, locations_df, on='State')
 3.  
 4. # Scatter plot of spending vs. voter turnout
 5. plt.figure(figsize=(10, 6))
 6. sns.scatterplot(x='Spending', y='Voter Turnout', data=merged_df, hue='State', palette='viridis', s=100)
 7. plt.title('Ad Spending vs. Voter Turnout')
 8. plt.xlabel('Ad Spending (in INR)')
 9. plt.ylabel('Voter Turnout (%)')
10. plt.show()
11.  
  1. Correlation Analysis
    Analyze the correlation between different variables to understand the relationships.
1. # Calculate correlation matrix
2. correlation_matrix = merged_df[['Spending', 'Voter Turnout', 'Votes']].corr()
3.  
4. # Plot correlation matrix
5. plt.figure(figsize=(8, 6))
6. sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm', linewidths=0.5)
7. plt.title('Correlation Matrix')
8. plt.show()
9.  

Step 5: Advanced Analysis

  1. Regression Analysis
    Perform a regression analysis to predict voter turnout based on ad spending.
 1. import statsmodels.api as sm
 2.  
 3. # Define the dependent and independent variables
 4. X = merged_df['Spending']
 5. y = merged_df['Voter Turnout']
 6.  
 7. # Add a constant to the independent variables
 8. X = sm.add_constant(X)
 9.  
10. # Create the regression model
11. model = sm.OLS(y, X).fit()
12.  
13. # Print the regression results
14. print(model.summary())
15.  

Explore Career Growth Article:- Why Regular Skill Updates are Crucial for Career Growth

Check out our Trending Courses Demo Playlist

Data Analytics with Power Bi and Fabric
Could Data Engineer
Data Analytics With Power Bi Fabic
AWS Data Engineering with Snowflake
Azure Data Engineering
Azure & Fabric for Power bi
Full Stack Power Bi
Subscribe to our channel & Don’t miss any update on trending technologies

Kick Start Your Career With Our Data Job

Master Fullstack Power BI – SQL, Power BI, Azure Cloud & Fabric Tools
Master in Data Science With Generative AI Transform Data into Business Solutions
Master Azure Data Engineering – Build Scalable Solutions for Big Data
Master AWS Data Engineering with Snowflake: Build Scalable Data Solutions
Transform Your Productivity With Low Code Technology: Master the Microsoft Power Platform

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *