ESMATUGBA commited on
Commit
663e322
·
verified ·
1 Parent(s): 88b52c1

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +13 -8
src/streamlit_app.py CHANGED
@@ -7,15 +7,20 @@ import seaborn as sns
7
  st.set_page_config(layout="wide", page_title="Gold Analysis Dashboard")
8
  plt.style.use('dark_background')
9
 
10
- # 1. VERİ YÜKLEME
11
  @st.cache_data
12
  def load_data():
13
- df = pd.read_csv("gld_price_data.csv")
 
14
  df['Date'] = pd.to_datetime(df['Date'])
15
  df['YEAR'] = df['Date'].dt.year
16
  return df
17
 
18
- df = load_data()
 
 
 
 
19
 
20
  # 2. SOL PANEL (SIDEBAR) - TIKLAYARAK SEÇME
21
  st.sidebar.markdown("# 📅 Filtreler / Filters")
@@ -33,13 +38,13 @@ filtered_df = df[df['YEAR'] == year]
33
  st.markdown("<h1 style='text-align: center;'>Gold Price Analysis / Altın Fiyat Analizi</h1>", unsafe_allow_html=True)
34
  st.divider()
35
 
36
- # 4. YÖNETİCİ BİLGİ NOTU (İSTEĞİN ÜZERİNE EN ÜSTTE)
37
- st.markdown("## 💼 Yönetici Bilgi Notu / Executive Summary") # ## ile başlık büyütüldü
38
  info_col1, info_col2 = st.columns(2)
39
 
40
  if year == 2008:
41
  with info_col1:
42
- st.warning("### 🇹🇷 2008'de altın güvenli limandır, alım faydalıdır.") # Yazı boyutu büyütüldü
43
  with info_col2:
44
  st.warning("### 🇺🇸 Gold is a safe haven in 2008; buying is beneficial.")
45
  else:
@@ -57,13 +62,13 @@ fig1, ax1 = plt.subplots(figsize=(8, 2.5))
57
  ax1.plot(filtered_df['Date'], filtered_df['GLD'], color='gold', linewidth=1.5)
58
  ax1.fill_between(filtered_df['Date'], filtered_df['GLD'], color='gold', alpha=0.1)
59
 
60
- # Eksen ayarı
61
  y_min, y_max = filtered_df['GLD'].min(), filtered_df['GLD'].max()
62
  ax1.set_ylim(y_min * 0.98, y_max * 1.02)
63
 
64
  st.pyplot(fig1)
65
 
66
- # GRAFİK NOTU (DAHA BÜYÜK VE OKUNAKLI)
67
  st.markdown(f"#### 📝 Not: Bu grafik {year} yılındaki günlük fiyat hareketlerini gösterir. / Note: This chart shows daily price movements in {year}.")
68
 
69
  st.divider()
 
7
  st.set_page_config(layout="wide", page_title="Gold Analysis Dashboard")
8
  plt.style.use('dark_background')
9
 
10
+ # 1. VERİ YÜKLEME (Dosya ismi düzeltildi)
11
  @st.cache_data
12
  def load_data():
13
+ # Hugging Face'teki dosya adın tam olarak bu:
14
+ df = pd.read_csv("gold_feature_engineered.csv")
15
  df['Date'] = pd.to_datetime(df['Date'])
16
  df['YEAR'] = df['Date'].dt.year
17
  return df
18
 
19
+ try:
20
+ df = load_data()
21
+ except Exception as e:
22
+ st.error(f"Dosya yükleme hatası: {e}")
23
+ st.stop()
24
 
25
  # 2. SOL PANEL (SIDEBAR) - TIKLAYARAK SEÇME
26
  st.sidebar.markdown("# 📅 Filtreler / Filters")
 
38
  st.markdown("<h1 style='text-align: center;'>Gold Price Analysis / Altın Fiyat Analizi</h1>", unsafe_allow_html=True)
39
  st.divider()
40
 
41
+ # 4. YÖNETİCİ BİLGİ NOTU (EN ÜSTTE)
42
+ st.markdown("## 💼 Yönetici Bilgi Notu / Executive Summary")
43
  info_col1, info_col2 = st.columns(2)
44
 
45
  if year == 2008:
46
  with info_col1:
47
+ st.warning("### 🇹🇷 2008'de altın güvenli limandır, alım faydalıdır.")
48
  with info_col2:
49
  st.warning("### 🇺🇸 Gold is a safe haven in 2008; buying is beneficial.")
50
  else:
 
62
  ax1.plot(filtered_df['Date'], filtered_df['GLD'], color='gold', linewidth=1.5)
63
  ax1.fill_between(filtered_df['Date'], filtered_df['GLD'], color='gold', alpha=0.1)
64
 
65
+ # Eksen ayarı (Basıklığı önlemek için veriye odaklanır)
66
  y_min, y_max = filtered_df['GLD'].min(), filtered_df['GLD'].max()
67
  ax1.set_ylim(y_min * 0.98, y_max * 1.02)
68
 
69
  st.pyplot(fig1)
70
 
71
+ # GRAFİK NOTU
72
  st.markdown(f"#### 📝 Not: Bu grafik {year} yılındaki günlük fiyat hareketlerini gösterir. / Note: This chart shows daily price movements in {year}.")
73
 
74
  st.divider()