Spaces:
Runtime error
Runtime error
File size: 3,755 Bytes
5e70003 e768cac 4848587 5e70003 e768cac 5e70003 659a817 6f887e2 e768cac 6f887e2 e768cac 6f887e2 e768cac 6f887e2 659a817 e768cac f6bd344 6f887e2 e768cac 659a817 e768cac f6bd344 e768cac 659a817 e768cac f6bd344 6f887e2 659a817 e768cac 5e70003 e768cac 5e70003 6f887e2 5e70003 e768cac 5e70003 6f887e2 5e70003 4848587 5e70003 4848587 5e70003 659a817 | 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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | 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ı.") |