text_plain_output_1.png image_output_1.png
import pandas as pd

poll = pd.read_csv('../input/2016-general-election-trump-vs-clinton.csv')

poll = poll.drop(['Pollster URL', 'Source URL', 'Partisan', 'Question Text', 'Question Iteration'], axis=1)

average = pd.DataFrame(poll.mean())
average.drop('Number of Observations', inplace=True)
average

std = pd.DataFrame(poll.std())
std.drop('Number of Observations', inplace=True)
std

from datetime import datetime
poll['Difference'] = (poll.Trump - poll.Clinton) / 100

poll = poll.groupby('Start Date', as_index=False).mean()

row_in = 0
xlimit = []
for date in poll['Start Date']:
    if date[0:7] == '2016-09':
        xlimit.append(row_in)
        row_in += 1
    else:
        row_in += 1
print(min(xlimit))
row_in = 0
xlimit = []
for date in poll['Start Date']:
    if date[0:7] == '2016-10':
        xlimit.append(row_in)
        row_in += 1
    else:
        row_in += 1
print(max(xlimit))