Skip to content

04-08: City Demographics Explorer (Pandas)

Python: Data Analytics

View the live site — ijk37.com

Project 08

Home  |  All Projects  |  Notes  |  Exercises  |  Quiz Hub

Explores city-level demographic data (population, literacy, income) for 6 Bangladesh cities over 4 years. Demonstrates pivot tables, pd.melt(), pd.concat(), gender gap analysis, and .str accessor methods.

Topics covered: df.pivot_table() · pd.melt() · pd.concat(keys=...) · .str.contains() · .str.len() · groupby().mean() · boolean indexing · df.pivot_table(aggfunc="mean")

Difficulty: ⭐⭐⭐ Intermediate–Advanced


Requirements

pip install pandas numpy

How to Run

python main.py

Key Concepts Practised

Concept Where used
df.pivot_table(values, index, columns, aggfunc) Population by city × year
pd.melt(id_vars, value_vars, var_name) Wide → long format
pd.concat([df1, df2], keys=...) Multi-year concat
df["City"].str.contains("a") String pattern filter
df["City"].str.len() String length filter
Pivot for gender gap pivot_table(index="City", columns="Gender")