Created
December 20, 2019 14:11
-
-
Save pmbaumgartner/4558781c0dfe8a4539201eaeb575ba51 to your computer and use it in GitHub Desktop.
How to use `format_func` with a streamlit widget and a dictionary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
from vega_datasets import data | |
@st.cache | |
def load_data(): | |
return data.birdstrikes() | |
cols = { | |
"Airport__Name": "Airport Name", | |
"Aircraft__Make_Model": "Aircraft Make & Model", | |
"Effect__Amount_of_damage": "Effect: Amount of Damage", | |
"Flight_Date": "Flight Date", | |
"Aircraft__Airline_Operator": "Airline Operator", | |
"Origin_State": "Origin State", | |
"When__Phase_of_flight": "When (Phase of Flight)", | |
"Wildlife__Size": "Wildlife Size", | |
"Wildlife__Species": "Wildlife Species", | |
"When__Time_of_day": "When (Time of Day)", | |
"Cost__Other": "Cost (Other)", | |
"Cost__Repair": "Cost (Repair)", | |
"Cost__Total_$": "Cost (Total) ($)", | |
"Speed_IAS_in_knots": "Speed (in Knots)", | |
} | |
dataset = load_data() | |
column = st.selectbox("Describe Column", list(dataset.columns), format_func=cols.get) | |
st.write(dataset[column].describe()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment