Sathwikchowdary commited on
Commit
b4b1ff8
·
verified ·
1 Parent(s): cc30398

Update pages/1player_information.py

Browse files
Files changed (1) hide show
  1. 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
- file_path = "Final_Team.csv"
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
- # 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)
 
 
 
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)