import streamlit as st import pandas as pd import matplotlib.pyplot as plt import seaborn as sns st.title("FIFA World Cup Analytics Dashboard") st.write( "Bu uygulama FIFA Dünya Kupası verileriyle şampiyonlukları, " "seyirci sayılarını, gol istatistiklerini ve takım performanslarını görselleştirir." ) st.image( "https://img.gazetemerhaba.com/rcman/Cw1280h720q95gc/storage/files/images/2025/12/07/dunya-kupasi-fifa-4ajh.jpg", use_container_width=True ) wc = pd.read_csv("src/world_cup.csv") matches = pd.read_csv("src/matches_1930_2022.csv") st.subheader("Genel Bilgiler") col1, col2, col3 = st.columns(3) col1.metric("Turnuva Sayısı", wc.shape[0]) col2.metric("Maç Sayısı", matches.shape[0]) col3.metric("Şampiyon Ülke Sayısı", wc["Champion"].nunique()) st.subheader("Dünya Kupası Şampiyonları") fig1, ax1 = plt.subplots(figsize=(10, 5)) wc["Champion"].value_counts().plot(kind="bar", ax=ax1) ax1.set_title("Dünya Kupası Şampiyonları") ax1.set_xlabel("Ülkeler") ax1.set_ylabel("Şampiyonluklar") st.pyplot(fig1) st.subheader("Yıllara Göre Dünya Kupası Seyirci Sayıları") fig2, ax2 = plt.subplots(figsize=(12, 5)) ax2.plot( wc["Year"], wc["Attendance"], marker="o" ) ax2.set_title("Yıllara Göre Dünya Kupası Seyirci Sayıları") ax2.set_xlabel("Yıl") ax2.set_ylabel("Katılım") ax2.grid() st.pyplot(fig2) st.subheader("En Fazla Dünya Kupasına Ev Sahipliği Yapan Ülkeler") fig4, ax4 = plt.subplots(figsize=(10, 5)) wc["Host"].value_counts().head(10).plot(kind="bar", ax=ax4) ax4.set_title("En Fazla Dünya Kupasına Ev Sahipliği Yapan Ülkeler") ax4.set_xlabel("Ülke") ax4.set_ylabel("Turnuva Sayısı") st.pyplot(fig4) st.subheader("Dünya Kupası Tarihinde En Fazla Maç Kazanan 10 Ülke") home_wins = matches["home_team"][ matches["home_score"] > matches["away_score"] ].value_counts() away_wins = matches["away_team"][ matches["away_score"] > matches["home_score"] ].value_counts() total_wins = home_wins.add(away_wins, fill_value=0) top10_wins = total_wins.sort_values(ascending=False).head(10) fig5, ax5 = plt.subplots(figsize=(12, 5)) top10_wins.plot(kind="bar", ax=ax5) ax5.set_title("Dünya Kupası Tarihinde En Fazla Maç Kazanan 10 Ülke") ax5.set_xlabel("Ülke") ax5.set_ylabel("Galibiyet Sayısı") st.pyplot(fig5) st.subheader("Dünya Kupası Tarihinde En Çok Gol Atan Ülkeler") home_goals = matches.groupby("home_team")["home_score"].sum() away_goals = matches.groupby("away_team")["away_score"].sum() total_goals_country = home_goals.add(away_goals, fill_value=0) top10_goals = total_goals_country.sort_values(ascending=False).head(10) fig6, ax6 = plt.subplots(figsize=(12, 5)) top10_goals.plot(kind="bar", ax=ax6) ax6.set_title("Dünya Kupası Tarihinde En Çok Gol Atan Ülkeler") ax6.set_xlabel("Ülke") ax6.set_ylabel("Gol Sayısı") st.pyplot(fig6) st.subheader("Dünya Kupası Şampiyonluk Dağılımı") champions = wc["Champion"].value_counts() fig7, ax7 = plt.subplots(figsize=(8, 8)) ax7.pie( champions, labels=champions.index, autopct="%1.1f%%", startangle=90 ) ax7.set_title("Dünya Kupası Şampiyonluk Dağılımı") st.pyplot(fig7) st.subheader("Maçlardaki Toplam Gol Dağılımı") matches["total_goals"] = matches["home_score"] + matches["away_score"] fig8, ax8 = plt.subplots(figsize=(10, 5)) ax8.hist( matches["total_goals"], bins=10 ) ax8.set_title("Maçlardaki Toplam Gol Dağılımı") ax8.set_xlabel("Maçtaki Toplam Gol") ax8.set_ylabel("Maç Sayısı") st.pyplot(fig8) st.subheader("Turnuva Aşamalarına Göre Gol Dağılımı") fig9, ax9 = plt.subplots(figsize=(14, 6)) sns.boxplot( data=matches, x="Round", y="total_goals", ax=ax9 ) ax9.set_title("Turnuva Aşamalarına Göre Gol Dağılımı") ax9.set_xlabel("Turnuva Aşaması") ax9.set_ylabel("Toplam Gol") plt.xticks(rotation=45) st.pyplot(fig9) st.subheader("Ev Sahibi ve Deplasman Gollerinin Dağılımı") goal_compare = matches[["home_score", "away_score"]] fig10, ax10 = plt.subplots(figsize=(8, 5)) sns.boxplot(data=goal_compare, ax=ax10) ax10.set_title("Ev Sahibi ve Deplasman Gollerinin Dağılımı") ax10.set_xlabel("Takım Türü") ax10.set_ylabel("Gol Sayısı") st.pyplot(fig10) st.subheader("Veri Setinden Örnekler") st.dataframe(wc.head())