File size: 2,850 Bytes
2b6a339
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6db5659
 
 
2b6a339
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
import plotly.express as px 
import plotly.graph_objects as go
import numpy as np


### CONFIG
st.set_page_config(
    page_title="E-commerce",
    page_icon="💸",
    layout="wide"
  )

### TITLE AND TEXT
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)

### EXPANDER
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 👇

""")

### LOAD AND CACHE DATA
#DATA_URL = ('https://626c476c-2f29-4366-9555-4aac80cfbe8a.filesusr.com/ugd/b8e5dd_44474a984ad54630b33bb9cf6d682259.csv?dn=athlete_events1.csv')

DATA_URL = ('https://ricoheric.github.io/streamlit/athlete_events.csv')

@st.cache_data # this lets the 
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("") # change text from "Loading data..." to "" once the the load_data function has run

## Run the below code if the check is checked ✅
if st.checkbox('Show raw data'):
    st.subheader('Raw data')
    st.write(data) 


### SHOW GRAPH STREAMLIT

st.subheader("Medals per Country")
medal_per_country = data.groupby("NOC")["Medal"].describe()  # Fix bar chart issue
st.bar_chart(medal_per_country)

### SHOW GRAPH PLOTLY + STREAMLIT

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)


### SIDEBAR
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("---")

#### CREATE TWO COLUMNS

@st.cache_data # this lets the 
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)