Spaces:
Runtime error
Runtime error
File size: 3,351 Bytes
0b3ccfc 6190c0d ec823d3 6190c0d 21ed593 6190c0d ec823d3 3d04254 ec823d3 3d04254 ec823d3 3d04254 ec823d3 3d04254 ec823d3 3d04254 ec823d3 3d04254 ec823d3 6190c0d 3d04254 ec823d3 21ed593 3d04254 ec823d3 3d04254 21ed593 ec823d3 6190c0d ec823d3 6190c0d 3d04254 6190c0d ec823d3 6190c0d ec823d3 3d04254 ec823d3 6190c0d 3d04254 6190c0d ec823d3 3d04254 ec823d3 6190c0d 3d04254 ec823d3 0b3ccfc 3d04254 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | import streamlit as st
import pandas as pd
import plotly.express as px
# Sayfa Ayarları
st.set_page_config(page_title="World Data Analysis", layout="wide")
# --- SIDEBAR (SOL PANEL) ---
with st.sidebar:
st.header("📊 Analysis Notes / Analiz Notları")
# 1. Genel Analiz Notları
st.markdown("""
**EN:** Analysis shows that developed countries have high GDP and internet usage. It has also been observed that CO2 emissions are high in these countries.
**TR:** Analiz sonucunda gelişmiş ülkelerde GDP ve internet kullanımının yüksek olduğu görülmüştür. Aynı zamanda bu ülkelerde CO2 emisyonunun da yüksek olduğu tespit edilmiştir.
""")
st.divider()
# 2. GDP SEVİYELERİ AÇIKLAMASI (YENİ EKLEDİĞİMİZ KISIM)
st.subheader("🔍 What are GDP Levels? / GDP Seviyeleri Nedir?")
st.markdown("""
**EN: GDP Categories**
* **High:** Global economic leaders with massive industrial output.
* **Medium:** Transitioning economies with growing industries.
* **Low:** Developing nations with smaller economies.
**TR: GDP Kategorileri**
* **High (Yüksek):** Sanayi üretimi devasa olan, dünya ekonomisine yön veren ülkeler.
* **Medium (Orta):** Sanayisi büyümekte olan, geçiş aşamasındaki ekonomiler.
* **Low (Düşük):** Ekonomisi daha küçük, gelişmekte olan ülkeler.
""")
# --- DATA LOAD ---
@st.cache_data
def load_data():
df = pd.read_csv("us_pollution_cleaned.csv")
# İsimleri Türkçeleştirme ve kısaltma
df = df.rename(columns={
'country': 'COUNTRY',
'GDP: Gross domestic product (million current US$)': 'GDP',
'CO2 emission estimates (million tons/tons per capita)': 'CO2'
})
# Gruplandırma (Bins değerlerini senin verine göre ayarladım)
df['GDP_LEVEL'] = pd.cut(df['GDP'], bins=[0, 50000, 1000000, 30000000], labels=['Low', 'Medium', 'High'])
return df
df = load_data()
# --- ANA PANEL ---
st.title("🌍 World Data Analysis Dashboard")
st.caption("Veri Analizi ve Görselleştirme / Data Analysis and Visualization")
st.divider()
# 1. HARİTA
st.subheader("🗺️ World GDP Map / Dünya GSYİH Haritası")
fig_map = px.choropleth(df,
locations="COUNTRY",
locationmode="country names",
color="GDP",
color_continuous_scale='Viridis',
labels={'GDP': 'GSYİH (Milyon $)'}, # Etiketi Türkçeleştirdik
height=450)
st.plotly_chart(fig_map, use_container_width=True)
st.divider()
# 2. ALT GRAFİKLER
col1, col2 = st.columns(2)
with col1:
st.subheader("📊 GDP vs CO2 (Interactive)")
fig_scatter = px.scatter(df, x="GDP", y="CO2",
color="GDP_LEVEL",
hover_name="COUNTRY",
labels={'GDP': 'GSYİH', 'CO2': 'CO2 Emisyonu', 'GDP_LEVEL': 'Gelir Grubu'},
template="plotly_white")
st.plotly_chart(fig_scatter, use_container_width=True)
with col2:
st.subheader("🍕 GDP Level Distribution / Gelir Dağılımı")
fig_pie = px.pie(df, names='GDP_LEVEL', values='GDP',
color_discrete_sequence=px.colors.sequential.RdBu,
hole=0.3)
st.plotly_chart(fig_pie, use_container_width=True)
st.write("✅ Veri temizleme ve görselleştirme başarıyla tamamlandı.") |