Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +44 -47
src/streamlit_app.py
CHANGED
|
@@ -56,50 +56,47 @@ else:
|
|
| 56 |
|
| 57 |
st.divider()
|
| 58 |
|
| 59 |
-
# 5.
|
| 60 |
-
st.
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
st.
|
| 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 |
-
|
| 103 |
-
|
| 104 |
-
csv = filtered_df.to_csv(index=False).encode('utf-8')
|
| 105 |
-
st.download_button("📥 Veriyi İndir / Download CSV", data=csv, file_name=f'gold_{year}.csv')
|
|
|
|
| 56 |
|
| 57 |
st.divider()
|
| 58 |
|
| 59 |
+
# 5. GRAFİKLER VE TABLO (Titremeyi önleyen Fragment yapısı)
|
| 60 |
+
@st.fragment
|
| 61 |
+
def render_analysis(data, selected_year):
|
| 62 |
+
st.markdown(f"## 📈 {selected_year} Analizi / Analysis")
|
| 63 |
+
|
| 64 |
+
# Ana Grafik
|
| 65 |
+
fig1, ax1 = plt.subplots(figsize=(8, 2.8))
|
| 66 |
+
ax1.plot(data['Date'], data['GLD'], color='gold', linewidth=2)
|
| 67 |
+
ax1.fill_between(data['Date'], data['GLD'], color='gold', alpha=0.1)
|
| 68 |
+
y_min, y_max = data['GLD'].min(), data['GLD'].max()
|
| 69 |
+
ax1.set_ylim(y_min * 0.98, y_max * 1.02)
|
| 70 |
+
st.pyplot(fig1)
|
| 71 |
+
plt.close(fig1)
|
| 72 |
+
|
| 73 |
+
st.markdown(f"#### 📝 Not: Bu grafik {selected_year} yılındaki günlük fiyat hareketlerini gösterir.")
|
| 74 |
+
st.divider()
|
| 75 |
+
|
| 76 |
+
# Yan Yana Grafikler
|
| 77 |
+
c1, c2 = st.columns(2)
|
| 78 |
+
with c1:
|
| 79 |
+
st.markdown("### 🎯 Dağılım / Distribution")
|
| 80 |
+
fig2, ax2 = plt.subplots(figsize=(5, 3.5))
|
| 81 |
+
sns.kdeplot(x=data['GLD'], fill=True, color="orange", ax=ax2)
|
| 82 |
+
st.pyplot(fig2)
|
| 83 |
+
plt.close(fig2)
|
| 84 |
+
with c2:
|
| 85 |
+
st.markdown("### 🌡️ Korelasyon / Correlation")
|
| 86 |
+
fig3, ax3 = plt.subplots(figsize=(5, 3.5))
|
| 87 |
+
num_df = data.select_dtypes(include=['number'])
|
| 88 |
+
sns.heatmap(num_df.corr(), annot=True, cmap='YlOrBr', ax=ax3, annot_kws={"size": 8})
|
| 89 |
+
st.pyplot(fig3)
|
| 90 |
+
plt.close(fig3)
|
| 91 |
+
|
| 92 |
+
st.divider()
|
| 93 |
+
|
| 94 |
+
# Veri Tablosu (Loglardaki width hatası için width='stretch' eklendi)
|
| 95 |
+
st.markdown("### 📋 Veri Tablosu / Data Table")
|
| 96 |
+
st.dataframe(data.head(10), width="stretch") # Logdaki hatayı bu düzeltecek
|
| 97 |
+
|
| 98 |
+
csv = data.to_csv(index=False).encode('utf-8')
|
| 99 |
+
st.download_button("📥 Veriyi İndir / Download CSV", data=csv, file_name=f'gold_{selected_year}.csv')
|
| 100 |
+
|
| 101 |
+
# Fonksiyonu çağır
|
| 102 |
+
render_analysis(filtered_df, year)
|
|
|
|
|
|
|
|
|