Spaces:
Sleeping
Sleeping
Update pages/1player_information.py
Browse files- pages/1player_information.py +62 -40
pages/1player_information.py
CHANGED
@@ -6,8 +6,7 @@ import matplotlib.pyplot as plt
|
|
6 |
st.set_page_config(page_title="Career Insights", layout="wide")
|
7 |
|
8 |
# Load data
|
9 |
-
|
10 |
-
df = pd.read_csv(file_path)
|
11 |
|
12 |
# Get unique player names
|
13 |
player_names = df["Player"].unique()
|
@@ -31,61 +30,84 @@ if selected_player:
|
|
31 |
col1, col2 = st.columns(2)
|
32 |
|
33 |
with col1:
|
34 |
-
#
|
35 |
-
|
36 |
-
player_data.get("
|
37 |
-
player_data.get("
|
38 |
-
player_data.get("
|
39 |
-
player_data.get("
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
]
|
41 |
fig, ax = plt.subplots()
|
42 |
-
ax.
|
43 |
-
ax.
|
|
|
|
|
|
|
44 |
st.pyplot(fig)
|
45 |
|
46 |
with col2:
|
47 |
-
#
|
48 |
-
|
49 |
-
player_data.get("
|
50 |
-
player_data.get("
|
51 |
-
player_data.get("
|
52 |
-
player_data.get("
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
]
|
54 |
fig, ax = plt.subplots()
|
55 |
-
ax.
|
56 |
-
ax.
|
57 |
-
ax.
|
|
|
|
|
58 |
st.pyplot(fig)
|
59 |
|
60 |
if show_bowling:
|
61 |
col1, col2 = st.columns(2)
|
62 |
|
63 |
with col1:
|
64 |
-
#
|
65 |
-
|
66 |
-
player_data.get("
|
67 |
-
player_data.get("
|
68 |
-
player_data.get("
|
69 |
-
player_data.get("
|
70 |
]
|
71 |
-
|
72 |
-
# Bar Chart - Overs Bowled
|
73 |
fig, ax = plt.subplots()
|
74 |
-
ax.bar(labels,
|
75 |
-
ax.set_ylabel("
|
76 |
-
ax.set_title(f"
|
77 |
st.pyplot(fig)
|
78 |
|
79 |
with col2:
|
80 |
-
#
|
81 |
-
|
82 |
-
player_data.get("
|
83 |
-
player_data.get("
|
84 |
-
player_data.get("
|
85 |
-
player_data.get("
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
]
|
87 |
fig, ax = plt.subplots()
|
88 |
-
ax.
|
89 |
-
ax.
|
90 |
-
ax.
|
91 |
-
|
|
|
|
|
|
6 |
st.set_page_config(page_title="Career Insights", layout="wide")
|
7 |
|
8 |
# Load data
|
9 |
+
df = pd.read_csv("Team_Info.csv")
|
|
|
10 |
|
11 |
# Get unique player names
|
12 |
player_names = df["Player"].unique()
|
|
|
30 |
col1, col2 = st.columns(2)
|
31 |
|
32 |
with col1:
|
33 |
+
# Bar Chart - 100s and 50s
|
34 |
+
hundreds = [
|
35 |
+
player_data.get("100s_Test", 0),
|
36 |
+
player_data.get("100s_ODI", 0),
|
37 |
+
player_data.get("100s_T20", 0),
|
38 |
+
player_data.get("100s_IPL", 0)
|
39 |
+
]
|
40 |
+
fifties = [
|
41 |
+
player_data.get("50s_Test", 0),
|
42 |
+
player_data.get("50s_ODI", 0),
|
43 |
+
player_data.get("50s_T20", 0),
|
44 |
+
player_data.get("50s_IPL", 0)
|
45 |
]
|
46 |
fig, ax = plt.subplots()
|
47 |
+
ax.bar(labels, hundreds, label="100s", color="gold")
|
48 |
+
ax.bar(labels, fifties, label="50s", color="blue", bottom=hundreds)
|
49 |
+
ax.set_ylabel("Count")
|
50 |
+
ax.set_title(f"Centuries & Fifties by {selected_player}")
|
51 |
+
ax.legend()
|
52 |
st.pyplot(fig)
|
53 |
|
54 |
with col2:
|
55 |
+
# Line Chart - Strike Rate & Average
|
56 |
+
strike_rate = [
|
57 |
+
player_data.get("SR_Test", 0),
|
58 |
+
player_data.get("SR_ODI", 0),
|
59 |
+
player_data.get("SR_T20", 0),
|
60 |
+
player_data.get("SR_IPL", 0)
|
61 |
+
]
|
62 |
+
batting_avg = [
|
63 |
+
player_data.get("Avg_Test", 0),
|
64 |
+
player_data.get("Avg_ODI", 0),
|
65 |
+
player_data.get("Avg_T20", 0),
|
66 |
+
player_data.get("Avg_IPL", 0)
|
67 |
]
|
68 |
fig, ax = plt.subplots()
|
69 |
+
ax.plot(labels, strike_rate, marker='o', linestyle='-', color='red', label="Strike Rate")
|
70 |
+
ax.plot(labels, batting_avg, marker='s', linestyle='--', color='green', label="Batting Average")
|
71 |
+
ax.set_ylabel("Value")
|
72 |
+
ax.set_title(f"Strike Rate & Batting Average of {selected_player}")
|
73 |
+
ax.legend()
|
74 |
st.pyplot(fig)
|
75 |
|
76 |
if show_bowling:
|
77 |
col1, col2 = st.columns(2)
|
78 |
|
79 |
with col1:
|
80 |
+
# Bar Chart - Economy Rate
|
81 |
+
economy_rate = [
|
82 |
+
player_data.get("Econ_Test", 0),
|
83 |
+
player_data.get("Econ_ODI", 0),
|
84 |
+
player_data.get("Econ_T20", 0),
|
85 |
+
player_data.get("Econ_IPL", 0)
|
86 |
]
|
|
|
|
|
87 |
fig, ax = plt.subplots()
|
88 |
+
ax.bar(labels, economy_rate, color=["purple", "orange", "cyan", "brown"])
|
89 |
+
ax.set_ylabel("Economy Rate")
|
90 |
+
ax.set_title(f"Economy Rate of {selected_player}")
|
91 |
st.pyplot(fig)
|
92 |
|
93 |
with col2:
|
94 |
+
# Scatter Plot - Bowling Average & Strike Rate
|
95 |
+
bowling_avg = [
|
96 |
+
player_data.get("Bowl_Avg_Test", 0),
|
97 |
+
player_data.get("Bowl_Avg_ODI", 0),
|
98 |
+
player_data.get("Bowl_Avg_T20", 0),
|
99 |
+
player_data.get("Bowl_Avg_IPL", 0)
|
100 |
+
]
|
101 |
+
bowling_sr = [
|
102 |
+
player_data.get("Bowl_SR_Test", 0),
|
103 |
+
player_data.get("Bowl_SR_ODI", 0),
|
104 |
+
player_data.get("Bowl_SR_T20", 0),
|
105 |
+
player_data.get("Bowl_SR_IPL", 0)
|
106 |
]
|
107 |
fig, ax = plt.subplots()
|
108 |
+
ax.scatter(labels, bowling_avg, color='blue', label="Bowling Average")
|
109 |
+
ax.scatter(labels, bowling_sr, color='red', label="Bowling Strike Rate")
|
110 |
+
ax.set_ylabel("Value")
|
111 |
+
ax.set_title(f"Bowling Average & Strike Rate of {selected_player}")
|
112 |
+
ax.legend()
|
113 |
+
st.pyplot(fig)
|