Python Project On Lokshabha Election
Python Project On Lokshabha Election
Python Project On Lokshabha Election
Project
File
Made by:-
Nikita kumari
Class- Xii ‘c’
Roll no. –
Topic:-
Python project on
lokshabha election.
CERTIFICATE
This is to certify that ________________
Roll no.:________ has successfully completed
the project work entitled project work is on
Lokshabha Election in the subject Informatics
Practices(065) laid down in the regulates of
CBSE for the purpose of practical examination
in class xii to be held in BR DAV Public
School dated on___________.
(S. Dutta )
(Internal) (External)
Signature: Signature:
Acknowledgement
This project work is on Lokshabha Election and has
been done as a part of my fulfillment of class XII
CBSE BOARD EXAMINATION 2020-2021. I would
like to convey my sincere gratitude to my principal
Mr. KK Sinha Sir for giving this opportunity to do
the project and extend my thanks to S. Dutta sir
for his valuable guidance, sublime suggestions and
generous help throughout the persuit of this
study. I wish to express my gratitude to my
parents for their sacrifice, patience ,
understanding and encouragement during the
entire project period.
INTRODUCTION
This python project on Lokshabha
Election is basically a database
based project done with help of
python language. This project is very
useful for the government to keep a
count on number of votes ,total
number of electors and how much
male and female voters etc. This
project is multifield project ,so that
it can be modified for various
purposes.
Python Project On Lokshabha Election
CODING -
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
def main_menu():
print("*************")
print("Read Data From File in different way")
print("1. Read complete csv file")
print("2. Reading complete file without index")
print("=============")
print("Data Visualisation")
print("3. Line Chart")
print("4. Bar Plot")
print("5. Pie Chart")
print("6. Scatter Chart")
print("============")
print("Apply Data Manipulation in the records of CSV file")
print("7. Sorting the data as per your choice")
print("8. Read top and bottom records from the file as per the requirement")
print("9.Make the copy of CSV file")
print("10. Read the Specific columns")
print("*************")
main_menu()
def ReadCSV():
print("Reading Data from CSv file")
df=pd.read_csv("E:\\Desktop\\My Files\\New folder\\nikita.csv")
print(df)
def no_index():
print("Reading Data from CSv file without index value")
df=pd.read_csv("E:\\Desktop\\My Files\\New folder\\nikita.csv",index_col=0)
print(df)
def new_column_name():
print("Adding new column name to existing data")
df=pd.read_csv("E:\\Desktop\\My Files\\New
folder\\ujjwalrajnew.csv",index_col=0,skiprows=1,names=['State name','total
vote'])
print(df)
def line_plot():
df=pd.read_csv("E:\\Desktop\\My Files\\New folder\\nikita.csv")
st=df['State Name']
te=df['Total Electors']
tav=df['Total Actual votes']
m=df['Male']
f=df['Female']
othr=df['Others']
plt.xlabel("State")
plt.xticks(rotation='vertical')
def pie_plot():
df=pd.read_csv("E:\\Desktop\\My Files\\New folder\\nikita.csv")
st=df['State Name']
te=df['Total Electors']
tav=df['Total Actual Votes']
m=df['Male']
f=df['Female']
othr=df['Other']
print("Select Specific Bar chart as given below:")
print("press 1 to print the data for State vs Total Electors")
print("press 2 to print the data for State vs Total actual votes")
print("press 3 to print the data for State vs Male ")
print("press 4 to print the data for State vs Female ")
print("press 5 to print the data for State vs Others ")
op=int(input("Enter your choice:"))
if op==1:
plt.title("state wise total electors")
plt.pie(te,labels=st,autopct="%3d%%")
plt.show()
elif op==2:
plt.title("state wise total actual votes")
plt.pie(m,labels=tav,autopct="%3d%%")
plt.show()
elif op==3:
plt.title("state wise male")
plt.pie(f,labels=m,autopct="%3d%%")
plt.show()
elif op==4:
plt.title("state wise female")
plt.pie(othr,labels=f,autopct="%3d%%")
plt.show()
elif op==5:
plt.title("state wise others")
plt.pie(f,labels=othr,autopct="%3d%%")
plt.show()
def scatter_plot():
df=pd.read_csv("E:\\Desktop\\My Files\\New folder\\nikita.csv")
st=df['State Name']
te=df['Total Electors']
tav=df['Total Actual Votes']
m=df['Male']
f=df['Female']
othr=df['Other']
ax=plt.gca()
ax.scatter(st,te,color='b',label="state wise total electors")
ax.scatter(st,tav,color='r',label="state wise total actual votes")
ax.scatter(st,m,color='g',label="state wise male")
ax.scatter(st,f,color='y',label="state wise female")
ax.scatter(st,othr,color='w',label="state wise others")
plt.xlabel("state")
plt.xticks(rotation='vertical')
plt.title("complete Scatter chart")
plt.legend()
plt.show()
def data_sorting():
df=pd.read_csv("E:\\Desktop\\My Files\\New folder\\nikita.csv")
print("press 1 to arrange the record as per the State name ")
print("press 2 to arrange the record as per the total electors ")
print("press 3 to arrange the record as per the total actual votes ")
print("press 4 to arrange the record as per the male ")
print("press 5 to arrange the record as per the female ")
print("press 6 to arrange the record as per the state others ")
op=int(input("enter your choice"))
if op==1:
df.sort_values(["State Name"],inplace=True)
print(df)
elif op==2:
df.sort_values(["Total Electors"],inplace=True)
print(df)
elif op==3:
df.sort_values(["Total Actual Votes"],inplace=True)
print(df)
elif op==4:
df.sort_values(["Male"],inplace=True)
print(df)
elif op==5:
df.sort_values(["Female"],inplace=True)
print(df)
elif op==6:
df.sort_values(["Other"],inplace=True)
print(df)
else:
print("enter valid input")
def top_bottom_selected_records():
df=pd.read_csv("E:\\Desktop\\My Files\\New folder\\nikita.csv",index_col=0)
top=int(input("how many records to display from top"))
print("First",top,"records")
print(df.head(top))
bottom=int(input("how many records to be displayed from bottom"))
print("last",bottom,"records")
print(df.tail(bottom))
def duplicate():
print("duplicate the file with new file")
df=pd.read_csv("E:\\Desktop\\My Files\\New folder\\nikita.csv")
df.to_csv("E:\\Desktop\\My Files\\New folder\\ nikita.csv")
print("data from the new file")
print(df)
def specific_col():
print("reading specific column from CSv file")
df=pd.read_csv("E:\\Desktop\\My Files\\New folder\\ nikita.csv")
print(df)
opt=int(input("enter your choice="))
if opt==1:
ReadCSV()
if opt==2:
no_index()
elif opt==3:
line_plot()
elif opt==4:
bar_plot()
elif opt==5:
pie_plot()
elif opt==6:
scatter_plot()
elif opt==7:
data_sorting()
elif opt==8:
top_bottom_selected_records()
elif opt==9:
duplicate()
elif opt==10:
specific_col()
else:
print("enter valid input")
OUTPUT -
When choice is 1 –
When choice is 4–
When choice is 5-
When choice is 7 –
When choice is 8 –
SOFTWARE REQIREMENT:
I.OPERATING SYSTEM : WINDOWS 7 AND
ABOVE
II. PROCESSOR : PENTIUM(ANY) OR AMD
ATHALON(3800+- 4200+ DUAL CORE)
III. MOTHERBOARD : 1.845 OR 915,995 FOR
PENTIUM 0R MSI
K9MM-V VIA K8M800+8237R PLUS CHIPSET FOR
AMD ATHALON
IV. RAM : 4GB+
V. Hard disk : 500GB
VIII. MONITOR : 14.1 or 15 -17 inch
IX. Key board and mouse : YES
X. Printer : (if print is required – [Hard copy])
SOFTWARE REQUIREMENTS:
• Windows OS
• Python
BIBLIOGRAPHY:
INFORMTICS PRACTISES WITH
PYTHON,
By Sumita Arora
WEBSITE:
https://www.wikipedia.org