-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapp.py
44 lines (32 loc) · 1.29 KB
/
app.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
import streamlit as st
import pandas as pd
import numpy as np
import plotly_express as px
st.markdown("<h1 style='text-align: left; color: green;'>Club and Nationality App</h1>", unsafe_allow_html=True)
st.write("")
@st.cache
def load_data():
df = pd.read_csv("football_data.csv")
df.drop(['Unnamed: 0', 'ID'], axis = 1, inplace=True)
return df
if st.checkbox("Select this checkbox to look at the data"):
st.write(load_data())
df = load_data()
clubs = st.sidebar.multiselect('Select Players for clubs', df['Club'].unique())
nationalities = st.sidebar.multiselect('Select Players from Nationalities', df['Nationality'].unique())
new_df = df[(df['Club'].isin(clubs)) & (df['Nationality'].isin(nationalities))]
if clubs and nationalities is not None:
if len(new_df) != 0:
st.write("Summary of the selected combination of club and nationality:")
st.write(new_df)
st.write("Simple chart between player age and overall age of all the players")
fig = px.scatter(new_df, x ='Overall',y='Age', color='Name')
st.plotly_chart(fig)
else:
# st.markdown("### No player with that combination was found!!!")
st.markdown(
"""
This very simple webapp allows you to select and visualize players from certain clubs and certain nationalities
👈 Select one or more clubs and nationalities
"""
)