Census data visualization

 import pandas as pd

import matplotlib.pyplot as plt
import seaborn as sns

df=pd.read_csv("/content/drive/MyDrive/Census2000")
df.head()

print(df.describe())
print(df.isnull().sum())
print(df["Age"].unique())



plt.figure(figsize=(12, 6))
sns.barplot(x="Age", y="People", hue="Year", data=df, palette="coolwarm")
#plt.xticks(rotation=45)
plt.title("Population Distribution by Age Group (1900 vs 2000)")
plt.xlabel("Age Group")
plt.ylabel("Population")
plt.legend(title="Year")
plt.show()


plt.figure(figsize=(10, 5))
sns.barplot(x="Sex", y="People", hue="Year", data=df, palette="Set1")
plt.title("Gender-wise Population Comparison (1900 vs 2000)")
plt.ylabel("Total Population")
plt.show()

plt.figure(figsize=(10, 6))
sns.boxplot(x="Year", y="People", data=df, palette="coolwarm")

plt.xlabel("Year")
plt.ylabel("Population Count")
plt.title("Box Plot of Population Distribution (1900 vs 2000)")
plt.show()




import matplotlib.pyplot as plt
import seaborn as sns

# Bar plot for People count by Sex (1900 vs 2000)
plt.figure(figsize=(6, 4))
sns.barplot(x='Sex', y='People', hue='Year', data=df, palette='viridis')
plt.title('People Count by Sex (1900 vs 2000)')
plt.xlabel('Sex')
plt.ylabel('People Count')
plt.legend(title='Year')
plt.show()

# Bar plot for Total People Count by Year (1900 vs 2000)
plt.figure(figsize=(6, 4))
sns.barplot(x='Year', y='People', data=df.groupby('Year').sum().reset_index(), palette='coolwarm')
plt.title('Total People Count by Year')
plt.xlabel('Year')
plt.ylabel('Total Population')
plt.show()

Comments