Spaces:
Sleeping
Sleeping
Update pages/1player_information.py
Browse files- pages/1player_information.py +58 -50
pages/1player_information.py
CHANGED
@@ -6,7 +6,7 @@ import matplotlib.pyplot as plt
|
|
6 |
st.set_page_config(page_title="Career Insights", layout="wide")
|
7 |
|
8 |
# Load data
|
9 |
-
file_path = "
|
10 |
df = pd.read_csv(file_path)
|
11 |
|
12 |
# Get unique player names
|
@@ -28,56 +28,64 @@ if selected_player:
|
|
28 |
labels = ["Test", "ODI", "T20", "IPL"]
|
29 |
|
30 |
if show_batting:
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
55 |
|
56 |
if show_bowling:
|
57 |
-
|
58 |
-
overs_bowled = [
|
59 |
-
player_data.get("bowling_Test_Balls", 0) // 6,
|
60 |
-
player_data.get("bowling_ODI_Balls", 0) // 6,
|
61 |
-
player_data.get("bowling_T20_Balls", 0) // 6,
|
62 |
-
player_data.get("bowling_IPL_Balls", 0) // 6
|
63 |
-
]
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
6 |
st.set_page_config(page_title="Career Insights", layout="wide")
|
7 |
|
8 |
# Load data
|
9 |
+
file_path = "Final.csv"
|
10 |
df = pd.read_csv(file_path)
|
11 |
|
12 |
# Get unique player names
|
|
|
28 |
labels = ["Test", "ODI", "T20", "IPL"]
|
29 |
|
30 |
if show_batting:
|
31 |
+
col1, col2 = st.columns(2)
|
32 |
+
|
33 |
+
with col1:
|
34 |
+
# Pie Chart - Matches Played Across Formats
|
35 |
+
matches = [
|
36 |
+
player_data.get("Matches_Test", 0),
|
37 |
+
player_data.get("Matches_ODI", 0),
|
38 |
+
player_data.get("Matches_T20", 0),
|
39 |
+
player_data.get("Matches_IPL", 0)
|
40 |
+
]
|
41 |
+
fig, ax = plt.subplots()
|
42 |
+
ax.pie(matches, labels=labels, autopct="%1.1f%%", startangle=90)
|
43 |
+
ax.set_title(f"Matches Played by {selected_player}")
|
44 |
+
st.pyplot(fig)
|
45 |
+
|
46 |
+
with col2:
|
47 |
+
# Bar Chart - Runs Scored
|
48 |
+
batting_runs = [
|
49 |
+
player_data.get("batting_Runs_Test", 0),
|
50 |
+
player_data.get("batting_Runs_ODI", 0),
|
51 |
+
player_data.get("batting_Runs_T20", 0),
|
52 |
+
player_data.get("batting_Runs_IPL", 0)
|
53 |
+
]
|
54 |
+
fig, ax = plt.subplots()
|
55 |
+
ax.bar(labels, batting_runs, color=["gold", "green", "blue", "red"])
|
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 |
+
col1, col2 = st.columns(2)
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
+
with col1:
|
64 |
+
# Calculate Overs Bowled
|
65 |
+
overs_bowled = [
|
66 |
+
player_data.get("bowling_Test_Balls", 0) // 6,
|
67 |
+
player_data.get("bowling_ODI_Balls", 0) // 6,
|
68 |
+
player_data.get("bowling_T20_Balls", 0) // 6,
|
69 |
+
player_data.get("bowling_IPL_Balls", 0) // 6
|
70 |
+
]
|
71 |
+
|
72 |
+
# Bar Chart - Overs Bowled
|
73 |
+
fig, ax = plt.subplots()
|
74 |
+
ax.bar(labels, overs_bowled, color=["purple", "orange", "cyan", "brown"])
|
75 |
+
ax.set_ylabel("Overs Bowled")
|
76 |
+
ax.set_title(f"Overs Bowled by {selected_player}")
|
77 |
+
st.pyplot(fig)
|
78 |
|
79 |
+
with col2:
|
80 |
+
# Line Chart - Wickets Taken
|
81 |
+
wickets_taken = [
|
82 |
+
player_data.get("bowling_Wickets_Test", 0),
|
83 |
+
player_data.get("bowling_Wickets_ODI", 0),
|
84 |
+
player_data.get("bowling_Wickets_T20", 0),
|
85 |
+
player_data.get("bowling_Wickets_IPL", 0)
|
86 |
+
]
|
87 |
+
fig, ax = plt.subplots()
|
88 |
+
ax.plot(labels, wickets_taken, marker='o', linestyle='-', color='red')
|
89 |
+
ax.set_ylabel("Wickets Taken")
|
90 |
+
ax.set_title(f"Wickets Taken by {selected_player}")
|
91 |
+
st.pyplot(fig)
|