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ı.")