-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHome.py
117 lines (115 loc) · 5.57 KB
/
Home.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import streamlit as st
import pandas as pd
import requests
from bs4 import BeautifulSoup
from io import StringIO
from tabulate import tabulate
pd.options.mode.chained_assignment = None
#
events_df = pd.read_csv('events.csv')
schedule_df = pd.read_csv('fbref_schedule.csv')
CURR_GW = events_df.loc[events_df['is_current'] == True]['id'].iloc[-1]
#
# page config
st.set_page_config(
page_title="Welcome to FPL Infographics", page_icon=":soccer:",layout="wide"
)
LOGO = "logo.png"
st.logo(
LOGO,
icon_image=LOGO,
)
# sidebar
with st.sidebar:
st.title(""":soccer: *FPL Infographics*""")
#
st.page_link("pages/1_Players_analysis.py", label="Player Analysis", icon=":material/analytics:",help="players performance, expected - goals, assists, involvements, shots, key passses, points per game, points per million and more..")
st.page_link("pages/2_Teams_analysis.py", label="Team Analysis", icon=":material/monitoring:",help="Team form, Each teams expected goals, expected goals against charts gives you a view of attack & defense permonce of the team over the season")
st.page_link("pages/3_Player_history.py", label="Player season history", icon=":material/history:",help="Player gameweek history with stats like expected,points,BPS")
st.page_link("pages/4_Team_form_&_FDR.py", label="FDR", icon=":material/flowsheet:",help="Fixture difficulty rating")
st.page_link("pages/6_Set_Piece_Takers.py", label="Set-Piece takers", icon=":material/flag:",help="Penalties, corners, free kicks - whos on them")
st.page_link("pages/8_Injuries_&_Cards.py", label="Injuries & Cards", icon=":material/style:",help="Latest injury news & Yellow, red cards table")
st.page_link("pages/9_Price_changes.py", label="Price changes & Predictions", icon=":material/currency_pound:",help="Today price change and predicted price changes for the next few days")
st.page_link("pages/12_Transfer_watchlist.py", label="Transfer recommondations", icon=":material/transfer_within_a_station:",help="Get your team performance, mini-league performance and Watch list picks based on expected goal involvements, points per game, Form, next gameweek expected points and Infuence+Creativity+Threat rank")
st.page_link("pages/10_Mini-league_Analyser.py", label="Mini-leagye (ML) Analyser", icon=":material/analytics:",help="Mini-league analysis - player ownership, captain choice, league race, each team xGI, bench points, team value")
st.page_link("pages/11_Compare_Teams.py", label="ML Teams comparision tool", icon=":material/compare_arrows:",help="compare teams from mini-league and see common picks and differentials + points by each position")
st.page_link("pages/fbref_compare.py", label="Players comparision tool", icon=":material/compare:",help="Compare player stats using radar charts for performance,shooting,passing,defensive stats")
st.page_link("pages/Expected_Points.py", label="Expected Points", icon=":material/psychology:",help="Expected points for selected gameweek")
st.page_link("pages/12_ALL_Player_Stats.py", label="ALL STATS", icon=":material/select_all:",help="All available stats for all players")
#
# landing
st.title(":soccer: :rainbow[*FPL Infographics*]")
st.subheader(
"""**Your Ultimate Fantasy Premier League analysis graphs!**
"""
)
# latest gameweek
st.markdown(
"##### Latest data update - Gameweek :blue["
+ str(CURR_GW)
+ """]
:blue[Use our latest data, stats, and models to prepare your team for success in Gameweek """
+ str(CURR_GW + 1)
+ ".]"
)
st.caption("FPL infographics can be incredibly helpful in making informed decisions by visualizing key stats and data in an easily digestible format. By transforming complex numbers and trends into graphs and tables, you can better understand player performances, team trends, and matchups.")
#
st.divider()
#
tab1, tab2, tab3 = st.tabs(["GW Results","Next Fixtures","Popular Transfers"])
with tab1:
st.markdown(
"##### GW:blue["
+ str(CURR_GW)
+ """]
"""
+ ""
)
results_df = schedule_df.loc[schedule_df['week'] == CURR_GW]
st.dataframe(
results_df,
column_order=("home_team","home_xg","score","away_xg","away_team"),
column_config={
"home_team": st.column_config.ImageColumn(),
"away_team": st.column_config.ImageColumn(),
},
hide_index=True,
)
with tab2:
st.markdown(
"##### GW:blue["
+ str(CURR_GW+1)
+ """]
"""
+ ""
)
fixture_df = schedule_df.loc[schedule_df['week'] == (CURR_GW+1)]
st.dataframe(
fixture_df,
column_order=('date','time',"home_team","score","away_team"),
column_config={
"home_team": st.column_config.ImageColumn(),
"away_team": st.column_config.ImageColumn(),
},
hide_index=True,
)
with tab3:
url = 'https://www.livefpl.net/prices' # Price Change prediction
header = ({'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'})
html_text = requests.get(url, headers=header).text
soup = BeautifulSoup(html_text, 'lxml')
table = soup.find_all('table')[2]
df = pd.read_html(StringIO(str(table)))[0]
headers = []
rows = []
for i, row in enumerate(table.find_all('tr')):
if i == 0:
headers = [el.text.strip() for el in row.find_all('th')]
else:
rows.append([el.text.strip() for el in row.find_all('td')])
table = tabulate(
rows,
headers=["State", "Predicted Rises", "Predicted Falls"],
tablefmt="rounded_grid"
)
st.dataframe(df,hide_index=True,height=1300)