Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions Problem_Statement2.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
#############################Problem 2:Constituency-Level Election Insights##############################

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
# Load the dataset
df=pd.read_csv(r"C:\Users\ayush\OneDrive\Desktop\PythonCA2\Data.csv")

###Objective 1: Identify constituencies with the highest and lowest number of candidates
# Count candidates per constituency
candidates_per_constituency = df.groupby('ac_name')['candidate_name'].nunique()
# Find the highest and lowest
highest_constituency = candidates_per_constituency.idxmax()
lowest_constituency = candidates_per_constituency.idxmin()
print(f"Constituency with highest candidates:{highest_constituency}({candidates_per_constituency.max()} candidates)")
print(f"Constituency with lowest candidates:{lowest_constituency}({candidates_per_constituency.min()} candidates)")

Expand Down