Sathwikchowdary commited on
Commit
e405c05
·
verified ·
1 Parent(s): 02a758a

Update pages/1player_information.py

Browse files
Files changed (1) hide show
  1. 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 = "Teams.csv"
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
- # Pie Chart - Matches Played Across Formats
32
- matches = [
33
- player_data.get("Matches_Test", 0),
34
- player_data.get("Matches_ODI", 0),
35
- player_data.get("Matches_T20", 0),
36
- player_data.get("Matches_IPL", 0)
37
- ]
38
- fig, ax = plt.subplots()
39
- ax.pie(matches, labels=labels, autopct="%1.1f%%", startangle=90)
40
- ax.set_title(f"Matches Played by {selected_player}")
41
- st.pyplot(fig)
42
-
43
- # Bar Chart - Runs Scored
44
- batting_runs = [
45
- player_data.get("batting_Runs_Test", 0),
46
- player_data.get("batting_Runs_ODI", 0),
47
- player_data.get("batting_Runs_T20", 0),
48
- player_data.get("batting_Runs_IPL", 0)
49
- ]
50
- fig, ax = plt.subplots()
51
- ax.bar(labels, batting_runs, color=["gold", "green", "blue", "red"])
52
- ax.set_ylabel("Runs Scored")
53
- ax.set_title(f"Runs Scored by {selected_player}")
54
- st.pyplot(fig)
 
 
 
 
55
 
56
  if show_bowling:
57
- # Calculate Overs Bowled
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
- # Bar Chart - Overs Bowled
66
- fig, ax = plt.subplots()
67
- ax.bar(labels, overs_bowled, color=["purple", "orange", "cyan", "brown"])
68
- ax.set_ylabel("Overs Bowled")
69
- ax.set_title(f"Overs Bowled by {selected_player}")
70
- st.pyplot(fig)
 
 
 
 
 
 
 
 
 
71
 
72
- # Line Chart - Wickets Taken
73
- wickets_taken = [
74
- player_data.get("bowling_Wickets_Test", 0),
75
- player_data.get("bowling_Wickets_ODI", 0),
76
- player_data.get("bowling_Wickets_T20", 0),
77
- player_data.get("bowling_Wickets_IPL", 0)
78
- ]
79
- fig, ax = plt.subplots()
80
- ax.plot(labels, wickets_taken, marker='o', linestyle='-', color='red')
81
- ax.set_ylabel("Wickets Taken")
82
- ax.set_title(f"Wickets Taken by {selected_player}")
83
- st.pyplot(fig)
 
 
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)