In this project, I analyzed a synthetic dataset of Nepal's hypothetical 2082 BS general election spanning 55 constituencies, 26 political parties, 215 candidates, and over 3,000 registered voters. Starting from 9 raw CSV files — covering everything from candidate profiles and voter demographics to campaign rallies, social media hashtags, media news coverage, and political scandals — I explored how these factors interrelate and ultimately shape election outcomes.
What I did:
- Loaded and cleaned all 9 datasets (parties, candidates, voters, votes, results, campaign events, social media trends, media news coverage, and political scandals), handling missing party IDs for independent candidates and Bikram Sambat calendar dates.
- Investigated candidate demographics (age, gender, education, criminal records, declared assets, campaign budgets) and voter turnout patterns across provinces, gender, and age groups.
- Analyzed campaign activity — rally attendance and media coverage scores — and their correlation with actual vote share.
- Measured social media sentiment (hashtag mentions and sentiment scores on TikTok, YouTube, Facebook, Twitter) and ran linear regressions against vote percentage.
- Examined media news coverage sentiment (positive, negative, neutral) per party and computed net sentiment ratios to assess media favorability.
- Assessed the impact of political scandals (corruption, financial misconduct, policy controversies) on candidates' vote share and win rates using statistical tests.
- Built a Random Forest model combining all these features to predict each candidate's vote percentage, and extracted feature importances to understand what matters most.
The outcome:
- Nepali Congress (NC) won the most seats — 20 out of 55 (36.4%) — led by Sher Bahadur Deuba, but fell short of the 28-seat majority threshold, resulting in a hung parliament.
- Scandals, media sentiment, social media buzz, and campaign spending all showed measurable associations with candidate performance, which the multi-factor model captures.
Disclaimer: All data in this project is entirely fictional and synthetically generated. It was created solely for educational and learning purposes. None of the data represents real election outcomes, real individuals, real political parties, or actual events. Any resemblance to real persons or organizations is purely coincidental and unintentional. Do not cite this data as factual or use it for any real-world decision-making.
Election-2082/
├── data/ # All CSV datasets
│ ├── political_parties_2082.csv
│ ├── candidates_2082.csv
│ ├── voters_2082.csv
│ ├── votes_2082.csv
│ ├── election_results_2082.csv
│ ├── campaign_events.csv
│ ├── social_media_trends.csv
│ ├── media_news_coverage.csv
│ └── political_scandals.csv
├── Analysis/
│ └── nepal_election_2082_analysis.ipynb # Main analysis notebook
├── scripts/
│ ├── export_images.py # Generate charts from CSVs
│ └── compute_winner.py # Compute election winner
├── images/ # Generated charts and predictions
├── .venv/ # Python virtual environment
└── Readme.md
| Table | Rows | Columns | Description |
|---|---|---|---|
political_parties_2082.csv |
26 | 9 | Party info: name, leader, ideology, members, symbol |
candidates_2082.csv |
215 | 12 | Candidate profiles: age, gender, education, assets, budget |
voters_2082.csv |
3,001 | 11 | Registered voters: demographics, location, voted flag |
votes_2082.csv |
2,010 | 5 | Individual vote records linking voters to candidates |
election_results_2082.csv |
215 | 7 | Aggregated results: vote count, percentage, rank per constituency |
campaign_events.csv |
351 | 7 | Campaign rallies, speeches, etc. with attendance and media scores |
social_media_trends.csv |
251 | 7 | Hashtag trends across platforms with sentiment scores |
media_news_coverage.csv |
301 | 7 | News articles with sentiment and impact scores |
political_scandals.csv |
81 | 6 | Scandal records with media attention and public reaction |
political_parties <──(party_id)── candidates <──(candidate_id)── election_results
│
(candidate_id)
│
┌────────────────┼────────────────┐
▼ ▼ ▼
campaign_events social_media_trends political_scandals
│
▼
media_news_coverage
voters ──(voter_id)──> votes <──(candidate_id)── candidates
party_idlinks parties to candidates and resultscandidate_idlinks candidates to votes, events, social media, news, and scandalsvoter_idlinks voters to their vote recordsconstituency_idis shared across candidates, voters, votes, and results
The notebook covers 20 analysis sections:
- Data Loading — Load all 9 CSV tables, verify row counts
- Data Inspection — Schema validation, dtypes, null checks
- Data Cleaning — Type casting, BS date handling, categorical encoding
- Join Integrity — Referential integrity checks across all tables
- Party Overview — Ideology distribution, membership, establishment timeline
- Candidate Demographics — Age, gender, education, profession, criminal status, budget
- Voter Demographics — Age, gender, province, urban/rural, education, occupation
- Voter Turnout — Overall and breakdown by province, gender, age, education
- Constituency Winners — Winner table, vote percentage chart, landslide detection
- Parliament Composition — Seat distribution, donut chart, proportionality analysis
- Constituency Competitiveness — Candidate counts, budget advantage proxy analysis
- Gender Representation — Win rates by gender, Mann-Whitney U test
- Campaign Activity — Events, attendance, media score vs vote correlation
- Social Media Sentiment — Sentiment and mentions vs vote share, linear regression
- Media News Coverage — Sentiment breakdown per party, net sentiment ratio
- Scandal Impact — Vote share and win rate comparison, statistical testing
- Controversial Candidates — Composite controversy score, bubble chart
- Wealth vs Outcome — Assets and budget vs win probability, logistic regression
- Timeline Analysis — Campaign events, social media, news over time
- Multi-Factor Model — Random Forest predicting vote percentage, feature importance
- Python 3.14
- pandas — data manipulation
- numpy — numerical operations
- matplotlib / seaborn — visualization
- scipy — statistical tests (Mann-Whitney U, Pearson, Spearman)
- scikit-learn — Linear Regression, Logistic Regression, Random Forest, cross-validation
# clone the repo
git clone <repo-url>
cd Election-2082
# create virtual environment
python -m venv .venv
.venv\Scripts\activate # Windows
# source .venv/bin/activate # Linux/Mac
# install dependencies
pip install pandas numpy matplotlib seaborn scipy scikit-learn
# open the notebook
jupyter notebook Analysis/nepal_election_2082_analysis.ipynb- Equal vote counts: In this synthetic dataset, every candidate in a constituency receives
vote_count = 100andvote_percentage = 100/N(where N = number of candidates). Traditional margin-of-victory analysis returns zero everywhere. The notebook uses alternative competitiveness proxies instead. - BS calendar dates: Dates like
2082-04-15are Bikram Sambat and cannot be parsed bypd.to_datetime(). They are kept as strings and sorted lexicographically. - 15 independent candidates have
party_id = NaN, handled with fillna in the analysis.
This project and its synthetic data are provided for educational purposes only.
Reminder: This is NOT real data. Everything — parties, candidates, voters, votes, results, scandals — is synthetically generated for learning. Do not treat any of it as factual.
To regenerate the charts from the CSVs (non-interactive):
.venv\Scripts\activate # Windows
python scripts/export_images.pyThis creates the following in images/:
| File | Description |
|---|---|
parliament.png |
Seat distribution bar + donut chart |
winner_vote_pct.png |
Winner vote % by constituency |
feature_importance.png |
Random Forest feature importance |
prediction_scatter.png |
Actual vs predicted vote % scatter |
predictions.csv |
Per-candidate actual & predicted vote % |



