Spaces:
Sleeping
Sleeping
Delete pages/viz2.py
Browse files- pages/viz2.py +0 -44
pages/viz2.py
DELETED
|
@@ -1,44 +0,0 @@
|
|
| 1 |
-
import pandas as pd
|
| 2 |
-
|
| 3 |
-
income_df = pd.read_csv('https://huggingface.co/spaces/jiyachachan/fp2/resolve/main/mincpcap_cppp.csv')
|
| 4 |
-
mortality_df = pd.read_csv('https://huggingface.co/spaces/jiyachachan/fp2/resolve/main/child_mortality_0_5_year_olds_dying_per_1000_born.csv')
|
| 5 |
-
|
| 6 |
-
income_long = pd.melt(income_df, id_vars=['country'], var_name='year', value_name='income')
|
| 7 |
-
mortality_long = pd.melt(mortality_df, id_vars=['country'], var_name='year', value_name='mortality')
|
| 8 |
-
|
| 9 |
-
income_long['year'] = income_long['year'].astype(int)
|
| 10 |
-
mortality_long['year'] = mortality_long['year'].astype(int)
|
| 11 |
-
|
| 12 |
-
yay = pd.merge(income_long, mortality_long, on=['country', 'year'])
|
| 13 |
-
|
| 14 |
-
yer = yay.dropna()
|
| 15 |
-
|
| 16 |
-
filtered_yer = yer[yer["year"] <= 2024]
|
| 17 |
-
|
| 18 |
-
# Visualization
|
| 19 |
-
|
| 20 |
-
import streamlit as st
|
| 21 |
-
import altair as alt
|
| 22 |
-
|
| 23 |
-
scatter_plot = alt.Chart(filtered_yer).mark_circle(size=60).encode(
|
| 24 |
-
x=alt.X(
|
| 25 |
-
'income',
|
| 26 |
-
title='Daily Income (USD)',
|
| 27 |
-
scale=alt.Scale(type='log', domain=[0.1, 10], base=10),
|
| 28 |
-
axis=alt.Axis(tickCount=10, grid=True, format='.1f')
|
| 29 |
-
),
|
| 30 |
-
y=alt.Y(
|
| 31 |
-
'mortality',
|
| 32 |
-
title='Child Mortality (per 1,000)',
|
| 33 |
-
axis=alt.Axis(tickCount=10, grid=True)
|
| 34 |
-
),
|
| 35 |
-
color='country',
|
| 36 |
-
tooltip=['country', 'year', 'income', 'mortality']
|
| 37 |
-
).properties(
|
| 38 |
-
width=700,
|
| 39 |
-
height=500,
|
| 40 |
-
title=f"Child Mortality vs Daily Income in {selected_year}"
|
| 41 |
-
)
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
st.altair_chart(scatter_plot, use_container_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|