|
|
import streamlit as st
|
|
|
import pandas as pd
|
|
|
import plotly.express as px
|
|
|
import plotly.graph_objects as go
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
st.set_page_config(
|
|
|
page_title="E-commerce",
|
|
|
page_icon="πΈ",
|
|
|
layout="wide"
|
|
|
)
|
|
|
|
|
|
|
|
|
st.title("Sport Heroes")
|
|
|
st.image("https://stillmed.olympic.org/media/Images/OlympicOrg/IOC/The_Organisation/The-Olympic-Rings/Olympic_rings_TM_c_IOC_All_rights_reserved_1.jpg", width=300)
|
|
|
|
|
|
|
|
|
st.subheader("Opening French Olympic Games")
|
|
|
with st.expander("β―οΈ Watch "):
|
|
|
st.video("https://youtu.be/6ldC6uHxHIc?si=94yBjIq41YakFQ1C")
|
|
|
|
|
|
st.subheader("The Raw Data")
|
|
|
st.markdown("""
|
|
|
All the __Heroes__ are in this Raw Datas π
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DATA_URL = ('https://ricoheric.github.io/streamlit/athlete_events.csv')
|
|
|
|
|
|
@st.cache_data
|
|
|
def load_data(nrows):
|
|
|
data = pd.read_csv(DATA_URL, nrows=nrows)
|
|
|
return data
|
|
|
|
|
|
data_load_state = st.text('Loading data...')
|
|
|
data = load_data(1000)
|
|
|
data_load_state.text("")
|
|
|
|
|
|
|
|
|
if st.checkbox('Show raw data'):
|
|
|
st.subheader('Raw data')
|
|
|
st.write(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
st.subheader("Medals per Country")
|
|
|
medal_per_country = data.groupby("NOC")["Medal"].describe()
|
|
|
st.bar_chart(medal_per_country)
|
|
|
|
|
|
|
|
|
|
|
|
st.subheader("All the Olympic Countries X events")
|
|
|
|
|
|
fig = px.histogram(data, x="Year", color='City', barmode="group")
|
|
|
st.plotly_chart(fig, use_container_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
st.sidebar.header("Build dashboards with Streamlit")
|
|
|
st.sidebar.markdown("""
|
|
|
* [Opening French Olympic Games](#opening-french-olympic-games)
|
|
|
* [Sport Heros Top](#sport-heroes)
|
|
|
* [Medals per Country](#medals-per-country)
|
|
|
* [Input Data](#input-data)
|
|
|
""")
|
|
|
e = st.sidebar.empty()
|
|
|
e.write("")
|
|
|
st.sidebar.write("Made with π by [Jedha](https://jedha.co)")
|
|
|
st.sidebar.image("Leon-Marchand.png")
|
|
|
|
|
|
|
|
|
|
|
|
st.markdown("---")
|
|
|
|
|
|
|
|
|
|
|
|
@st.cache_data
|
|
|
def load_datam():
|
|
|
datam = pd.read_csv(DATA_URL)
|
|
|
return datam
|
|
|
datam = load_datam()
|
|
|
st.markdown("**1οΈβ£ Example of input widget**")
|
|
|
country = st.selectbox("Select a country you want to see all the medals", datam["NOC"].sort_values().unique())
|
|
|
country_medal = datam[datam["NOC"]==country].groupby('Medal')['Sex'].value_counts().reset_index()
|
|
|
fig = px.bar(country_medal, x='Medal', y='count', color='Sex', barmode='group')
|
|
|
fig.update_layout(bargap=0.2)
|
|
|
st.plotly_chart(fig, use_container_width=True)
|
|
|
|
|
|
|