Charts and Graphs with Python

In my code looking at the congress dataset, I mainly looked at military experience and time served in office and graphed the data using python. The link will be down below and ensure the dataset is named 'Congress.csv'.

https://colab.research.google.com/drive/1hmc9hK_ZTVLS1lvLBKOLs9j-_CmHQMDs?usp=sharing

Edit: these were the images that popped up on my end, here is the code used as well:

import pandas as pd
import matplotlib.pyplot as plt

# Read the CSV file
data = pd.read_csv("Congress.csv")

# Plotting military experience
plt.figure(figsize=(10, 5))
data['COL_MIL'].value_counts().plot(kind='bar', color='blue')
plt.title('Military Experience Distribution in Congress')
plt.xlabel('Military Experience')
plt.ylabel('Number of Congress Members')
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()

# Plotting total years
plt.figure(figsize=(10, 5))
plt.hist(data['TOT_YRS'].dropna(), bins=20, color='green')
plt.title('Total Years Distribution in Congress')
plt.xlabel('Total Years')
plt.ylabel('Number of Congress Members')
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()




Comments