Sathwikchowdary commited on
Commit
03b9d6c
·
verified ·
1 Parent(s): 08bd507

Update pages/1player_information.py

Browse files
Files changed (1) hide show
  1. pages/1player_information.py +11 -89
pages/1player_information.py CHANGED
@@ -26,13 +26,12 @@ if selected_player:
26
  player_data = df[df["Player"] == selected_player].iloc[0]
27
  labels = ["Test", "ODI", "T20", "IPL"]
28
 
29
- # **Batting Stats Section**
30
  if show_batting:
31
- st.subheader(f"Batting Statistics - {selected_player}")
32
- col1, col2 = st.columns(2)
33
 
 
34
  with col1:
35
- # Pie Chart - Matches Played Across Formats
36
  matches = [
37
  player_data.get("Matches_Test", 0),
38
  player_data.get("Matches_ODI", 0),
@@ -57,102 +56,25 @@ if selected_player:
57
  ax.set_ylabel("Runs Scored")
58
  ax.set_title(f"Runs Scored by {selected_player}")
59
  st.pyplot(fig)
60
-
61
- col3, col4 = st.columns(2)
62
-
63
- with col3:
64
- # Bar Chart - 100s and 50s
65
- hundreds = [
66
- player_data.get("batting_100s_Test", 0),
67
- player_data.get("batting_100s_ODI", 0),
68
- player_data.get("batting_100s_T20", 0),
69
- player_data.get("batting_100s_IPL", 0)
70
- ]
71
- fifties = [
72
- player_data.get("batting_50s_Test", 0),
73
- player_data.get("batting_50s_ODI", 0),
74
- player_data.get("batting_50s_T20", 0),
75
- player_data.get("batting_50s_IPL", 0)
76
- ]
77
- fig, ax = plt.subplots()
78
- ax.bar(labels, hundreds, label="100s", color="gold")
79
- ax.bar(labels, fifties, label="50s", color="blue", bottom=hundreds)
80
- ax.set_ylabel("Count")
81
- ax.set_title(f"Centuries & Fifties by {selected_player}")
82
- ax.legend()
83
- st.pyplot(fig)
84
-
85
- with col4:
86
- # Line Chart - Strike Rate & Average
87
- strike_rate = [
88
- player_data.get("batting_SR_Test", 0),
89
- player_data.get("batting_SR_ODI", 0),
90
- player_data.get("batting_SR_T20", 0),
91
- player_data.get("batting_SR_IPL", 0)
92
- ]
93
- batting_avg = [
94
- player_data.get("batting_Average_Test", 0),
95
- player_data.get("batting_Average_ODI", 0),
96
- player_data.get("batting_Average_T20", 0),
97
- player_data.get("batting_Average_IPL", 0)
98
- ]
99
- fig, ax = plt.subplots()
100
- ax.plot(labels, strike_rate, marker='o', linestyle='-', color='red', label="Strike Rate")
101
- ax.plot(labels, batting_avg, marker='s', linestyle='--', color='green', label="Batting Average")
102
- ax.set_ylabel("Value")
103
- ax.set_title(f"Strike Rate & Batting Average of {selected_player}")
104
- ax.legend()
105
- st.pyplot(fig)
106
 
107
- # **Bowling Stats Section**
108
  if show_bowling:
109
- st.subheader(f"Bowling Statistics - {selected_player}")
110
- col1, col2 = st.columns(2)
111
 
 
112
  with col1:
113
- # Pie Chart - Wickets Taken Across Formats
114
  wickets = [
115
- player_data.get("Wickets_Test", 0),
116
- player_data.get("Wickets_ODI", 0),
117
- player_data.get("Wickets_T20", 0),
118
- player_data.get("Wickets_IPL", 0)
119
  ]
120
- fig, ax = plt.subplots(figsize=(5, 3))
121
  ax.pie(wickets, labels=labels, autopct="%1.1f%%", startangle=90)
122
  ax.set_title(f"Wickets Taken by {selected_player}")
123
  st.pyplot(fig)
124
 
125
  with col2:
126
- # Bar Chart - Economy Rate
127
- economy_rate = [
128
- player_data.get("Economy_Test", 0),
129
- player_data.get("Economy_ODI", 0),
130
- player_data.get("Economy_T20", 0),
131
- player_data.get("Economy_IPL", 0)
132
- ]
133
- fig, ax = plt.subplots(figsize=(5, 3))
134
- ax.bar(labels, economy_rate, color=["gold", "green", "blue", "red"])
135
- ax.set_ylabel("Economy Rate")
136
- ax.set_title(f"Economy Rate of {selected_player}")
137
- st.pyplot(fig)
138
-
139
- col3, col4 = st.columns(2)
140
-
141
- with col3:
142
- # Bar Chart - Balls Bowled
143
- balls_bowled = [
144
- player_data.get("bowling_Balls_Test", 0),
145
- player_data.get("bowling_Balls_ODI", 0),
146
- player_data.get("bowling_Balls_T20", 0),
147
- player_data.get("bowling_Balls_IPL", 0)
148
- ]
149
- fig, ax = plt.subplots(figsize=(5, 3))
150
- ax.bar(labels, balls_bowled, color=["red", "green", "blue", "purple"])
151
- ax.set_ylabel("Balls Bowled")
152
- ax.set_title(f"Balls Bowled by {selected_player}")
153
- st.pyplot(fig)
154
-
155
- with col4:
156
  # Bar Chart - Maidens Bowled
157
  maidens_bowled = [
158
  player_data.get("bowling_Maidens_Test", 0),
 
26
  player_data = df[df["Player"] == selected_player].iloc[0]
27
  labels = ["Test", "ODI", "T20", "IPL"]
28
 
 
29
  if show_batting:
30
+ st.subheader(f"Batting Stats for {selected_player}")
 
31
 
32
+ col1, col2 = st.columns(2)
33
  with col1:
34
+ # Pie Chart - Matches Played
35
  matches = [
36
  player_data.get("Matches_Test", 0),
37
  player_data.get("Matches_ODI", 0),
 
56
  ax.set_ylabel("Runs Scored")
57
  ax.set_title(f"Runs Scored by {selected_player}")
58
  st.pyplot(fig)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
 
60
  if show_bowling:
61
+ st.subheader(f"Bowling Stats for {selected_player}")
 
62
 
63
+ col1, col2 = st.columns(2)
64
  with col1:
65
+ # Pie Chart - Wickets Taken
66
  wickets = [
67
+ 0 if pd.isna(player_data.get("bowling_Test_Avg", 0)) else float(player_data.get("bowling_Test_Avg", 0)),
68
+ 0 if pd.isna(player_data.get("bowling_ODI_Wickets", 0)) else int(player_data.get("bowling_ODI_Wickets", 0)),
69
+ 0 if pd.isna(player_data.get("bowling_T20_Wickets", 0)) else int(player_data.get("bowling_T20_Wickets", 0)),
70
+ 0 if pd.isna(player_data.get("bowling_IPL_Wickets", 0)) else int(player_data.get("bowling_IPL_Wickets", 0))
71
  ]
72
+ fig, ax = plt.subplots()
73
  ax.pie(wickets, labels=labels, autopct="%1.1f%%", startangle=90)
74
  ax.set_title(f"Wickets Taken by {selected_player}")
75
  st.pyplot(fig)
76
 
77
  with col2:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  # Bar Chart - Maidens Bowled
79
  maidens_bowled = [
80
  player_data.get("bowling_Maidens_Test", 0),