Skip to content

Instantly share code, notes, and snippets.

@tvst
Created October 2, 2019 06:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tvst/713f5804ab45b9430866ee639d8568f1 to your computer and use it in GitHub Desktop.
Save tvst/713f5804ab45b9430866ee639d8568f1 to your computer and use it in GitHub Desktop.
import streamlit as st
import pandas as pd
@st.cache
def get_data():
return pd.read_csv('https://datahub.io/core/gdp/r/gdp.csv')
'# World GDP'
df = get_data()
min_year = int(df['Year'].min())
max_year = int(df['Year'].max())
countries = df['Country Name'].unique()
'## By country'
country = st.selectbox('Country', countries)
df[df['Country Name'] == country]
'## By year'
year = st.slider('Year', min_year, max_year)
df[df['Year'] == year]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment