Sathwikchowdary commited on
Commit
fcb92fa
·
verified ·
1 Parent(s): d54e14b

Update pages/1player_information.py

Browse files
Files changed (1) hide show
  1. pages/1player_information.py +56 -0
pages/1player_information.py CHANGED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import matplotlib.pyplot as plt
4
+ import seaborn as sns
5
+
6
+ # Load data
7
+ file_path = "South_Africa_Final2.csv"
8
+ df = pd.read_csv(file_path)
9
+
10
+ st.title("South Africa Cricket Players - Career Visualizations")
11
+
12
+ # Enter Player Name
13
+ player_input = st.text_input("Enter Player Name:")
14
+
15
+ if player_input:
16
+ selected_player = player_input.strip()
17
+ if selected_player in df["Player"].values:
18
+ player_data = df[df["Player"] == selected_player].iloc[0]
19
+
20
+ # Pie Chart - Matches Played Across Formats
21
+ matches = [
22
+ player_data["Matches_Test"],
23
+ player_data["Matches_ODI"],
24
+ player_data["Matches_T20"],
25
+ player_data["Matches_IPL"]
26
+ ]
27
+ labels = ["Test", "ODI", "T20", "IPL"]
28
+ fig, ax = plt.subplots()
29
+ ax.pie(matches, labels=labels, autopct="%1.1f%%", startangle=90, colors=["blue", "green", "red", "purple"])
30
+ ax.set_title(f"Matches Played by {selected_player}")
31
+ st.pyplot(fig)
32
+
33
+ # Bar Chart - Runs Scored in Different Formats
34
+ batting_runs = [
35
+ player_data["batting_Runs_Test"],
36
+ player_data["batting_Runs_ODI"],
37
+ player_data["batting_Runs_T20"],
38
+ player_data["batting_Runs_IPL"]
39
+ ]
40
+ fig, ax = plt.subplots()
41
+ ax.bar(labels, batting_runs, color=["blue", "green", "red", "purple"])
42
+ ax.set_ylabel("Runs Scored")
43
+ ax.set_title(f"Runs Scored by {selected_player}")
44
+ st.pyplot(fig)
45
+
46
+ # Scatter Plot - Matches vs Runs
47
+ fig, ax = plt.subplots()
48
+ sns.scatterplot(x=df["Matches_ODI"], y=df["batting_Runs_ODI"], ax=ax)
49
+ ax.set_xlabel("Matches Played")
50
+ ax.set_ylabel("Runs Scored")
51
+ ax.set_title("Matches vs Runs in ODIs (All Players)")
52
+ st.pyplot(fig)
53
+ else:
54
+ st.error("Player not found! Please enter a valid player name.")
55
+
56
+ st.write("Enter a player's name to explore their statistics!")