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") # --- DATA LOAD --- @st.cache_data def load_data(): df = pd.read_csv("us_pollution_cleaned.csv") 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 df['GDP_LEVEL'] = pd.cut(df['GDP'], bins=[0, 50000, 1000000, 30000000], labels=['Low', 'Medium', 'High']) return df df = load_data() # --- SIDEBAR (SOL PANEL) - TÜMÜ ÇİFT DİL VE NET --- with st.sidebar: st.header("📊 Analysis Notes / 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() st.subheader("🔍 What are GDP Levels? / GDP Seviyeleri Nedir?") # HIGH (İngilizce & Türkçe & Örnekler) high_list = "USA, China, Japan, Germany" st.markdown(f""" **🔴 High (Yüksek):** * **EN:** Global economic leaders with massive industrial output. * **TR:** Sanayi üretimi devasa olan, dünya ekonomisine yön veren ülkeler. * **Examples/Örnekler:** **{high_list}** """) st.write("") # Boşluk # MEDIUM (İngilizce & Türkçe & Örnekler) med_list = "Turkey, Argentina, Poland, Thailand" st.markdown(f""" **🟡 Medium (Orta):** * **EN:** Transitioning economies with growing industries. * **TR:** Sanayisi büyümekte olan, geçiş aşamasındaki ekonomiler. * **Examples/Örnekler:** **{med_list}** """) st.write("") # Boşluk # LOW (İngilizce & Türkçe & Örnekler) low_list = "Afghanistan, Gambia, Andorra, Belize" st.markdown(f""" **🟢 Low (Düşük):** * **EN:** Developing nations with smaller economies. * **TR:** Ekonomisi daha küçük, gelişmekte olan ülkeler. * **Examples/Örnekler:** **{low_list}** """) # --- ANA PANEL BAŞLIK (GÜNCELLENDİ) --- st.title("🌍 World Data Analysis Dashboard / Dünya Veri Analizi Paneli") 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 $)'}, 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) / GSYİH ve CO2 İlişkisi") 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("✅ Project completed. / Proje tamamlandı.")