Week 05
Week 05
Pathak, Anurag N
Atla, Rajeev R
Haque, Suhail
Nimmala, Thanvi
Gurbanov, Danny
This dataset contains columns on political polling, specifically regarding different pollsters,
modes of polling, sample sizes, political affiliations, and results for Democratic, Republican, and
independent candidates.
Bar chart
Python Code
import pandas as pd
data = pd.read_csv(file_path)
# Display the first few rows of the dataset to understand its structure
2
data.head(), data.columns
Above is the first visualization—a bar chart of the average supports for the Democratic and
Republican candidates. It seems obvious from the visualization that the average support between
both Democrats and Republicans is almost equal.
Line chart
Below is a line chart which visualizes the trend in support for both parties over time. This chart
highlights the fluctuations in support for both parties as the election date approaches.
Python code
# Group by election date and calculate the mean support for each date
# Visualization 2: Line chart showing the trend in support for Democratic and Republican
candidates over time
3
plt.figure(figsize=(12, 8))
plt.xlabel('Election Date')
plt.legend()
plt.grid(True)
plt.show()