In [2]:
import seaborn as sns
import pandas as pd
import matplotlib as plt
In [3]:
df = pd.read_csv(r"C:\Users\Anjan\Downloads\elections.csv")
In [4]:
df.head()
Out[4]:
st_name year ac_no ac_name ac_type cand_name cand_sex partyname partyabbre totvotpoll electors
0 Andhra Pradesh 1978.0 1 Ichapuram GEN Manabala Ramarao M Independent IND 813.0 83247
1 Andhra Pradesh 1978.0 1 Ichapuram GEN Appadu Sahu M Independent IND 1743.0 83247
2 Andhra Pradesh 1978.0 1 Ichapuram GEN Uppada Rangababu M Indian National Congress INC 4427.0 83247
3 Andhra Pradesh 1978.0 1 Ichapuram GEN Kalla Balarama Swamy M Indian National Congress (I) INC(I) 19805.0 83247
4 Andhra Pradesh 1978.0 1 Ichapuram GEN Bendalam Venkatesam Sarma M Janata Party JNP 34251.0 83247
In [8]:
df['st_name'].unique().__len__()
Out[8]:
30
In [14]:
years = df['year'].unique()
years.sort()
print(years)
[1977.  1978.  1979.  1980.  1982.  1983.  1984.  1985.  1987.  1989.
 1990.  1991.  1992.  1993.  1994.  1995.  1996.  1997.  1998.  1999.
 2000.  2001.  2002.  2003.  2004.  2005.  2005.1 2006.  2007.  2008.
 2009.  2010.  2011.  2012.  2013.  2014.  2015. ]
In [21]:
temp = df[df['st_name'] == 'Bihar']
In [24]:
sns.lineplot(data=temp, x='year', y='electors')
Out[24]:
<AxesSubplot:xlabel='year', ylabel='electors'>
In [25]:
temp = df[df['st_name'] == 'Uttar Pradesh']
In [27]:
temp = temp[temp['year'] == 2012.0]
In [28]:
temp.head()
Out[28]:
st_name year ac_no ac_name ac_type cand_name cand_sex partyname partyabbre totvotpoll electors
305548 Uttar Pradesh 2012.0 1 Behat GEN Mahmood M LD LD 565.0 303273
305549 Uttar Pradesh 2012.0 1 Behat GEN Irshad Urf Bhoora M RLM RLM 593.0 303273
305550 Uttar Pradesh 2012.0 1 Behat GEN Vikram M VAJP VAJP 702.0 303273
305551 Uttar Pradesh 2012.0 1 Behat GEN Abdul Jabbar M NCP NCP 726.0 303273
305552 Uttar Pradesh 2012.0 1 Behat GEN Yashpal M ABHM ABHM 781.0 303273
In [36]:
ac_no = temp['ac_no'].unique()
temp1 = temp[temp['ac_name'] == 'Ghazipur']
In [39]:
temp1.__len__()
Out[39]:
16
In [41]:
sns.barplot(data=temp1, x='partyname', y='totvotpoll')
Out[41]:
<AxesSubplot:xlabel='partyname', ylabel='totvotpoll'>
In [48]:
temp1 = df[df['ac_name'] == 'Lucknow East']
temp1 = temp1[temp1['ac_type'] == 'SC']
In [46]:
# sns.lineplot(data=temp1, x='')
temp1.head()
Out[46]:
st_name year ac_no ac_name ac_type cand_name cand_sex partyname partyabbre totvotpoll electors
308360 Uttar Pradesh 2012.0 173 Lucknow East GEN Juhie Singh F SP SP 47908.0 356340
In [49]:
ac_types = df['ac_type'].unique()
In [51]:
sns.countplot(data=df, x='ac_type')
# total over period of 1979 to 2015
Out[51]:
<AxesSubplot:xlabel='ac_type', ylabel='count'>
In [ ]: