Spaces:
Runtime error
Runtime error
File size: 4,357 Bytes
47a37b2 d9d1929 a2c8759 d9d1929 8150319 a2c8759 d22ed3d 8150319 d22ed3d 8150319 d22ed3d 8150319 d22ed3d 8150319 d22ed3d 8150319 d22ed3d 8150319 d22ed3d |
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 |
import streamlit as st
import pandas as pd
import random
# Constants
AI = 'π€'
DATA = 'π'
EMOJIS = ['π€£', 'π', 'π', 'π€ͺ', 'π', 'π€']
# Magic commands
st.set_page_config(page_title='Streamlit Super Power Cheat Sheet - Gamified')
st.set_option('deprecation.showfileUploaderEncoding', False)
# ------------------------- PLAYER CARDS -------------------------
player1 = [
{'Word': 'Strategy', 'Definition': 'A plan of action designed to achieve a long-term or overall aim.'},
{'Word': 'Economics', 'Definition': 'The branch of knowledge concerned with the production, consumption, and transfer of wealth.'},
{'Word': 'Industry', 'Definition': 'Economic activity concerned with the processing of raw materials and manufacture of goods in factories.'}
]
player2 = [
{'Word': 'Manufacturing', 'Definition': 'The making of articles on a large scale using machinery.'},
{'Word': 'Transportation', 'Definition': 'The action of transporting someone or something or the process of being transported.'},
{'Word': 'Community', 'Definition': 'A group of people living in the same place or having a particular characteristic in common.'}
]
df_player1 = pd.DataFrame(player1)
df_player2 = pd.DataFrame(player2)
df_matches = pd.merge(df_player1, df_player2, on='Word')
st.dataframe(df_matches)
match_count = df_matches.shape[0]
st.write(f'Number of word matches: {match_count}')
if match_count > 0:
random_match = df_matches.iloc[random.randint(0, match_count-1)]
st.write(f'Random match: {random_match["Word"]}')
st.write(f'{random_match["Definition_x"]}')
st.write(f'{random_match["Definition_y"]}')
else:
st.write('No word matches')
# ------------------------- STRATEGY DATA -------------------------
strategy_data = [
{'Classification': 'Economic', 'Definition': 'π° The branch of knowledge concerned with the production, consumption, and transfer of wealth.'},
{'Classification': 'Industry', 'Definition': 'π Economic activity concerned with the processing of raw materials and manufacture of goods in factories.'},
{'Classification': 'Manufacturing', 'Definition': 'π The making of articles on a large scale using machinery.'},
{'Classification': 'Development', 'Definition': 'ποΈ The process of growth, progress, or realization of goals.'},
{'Classification': 'Transport', 'Definition': 'π The movement of people, goods, or materials from one place to another.'},
{'Classification': 'Income', 'Definition': 'πΈ The money received by a person, company, or country for work, services, or investment.'},
{'Classification': 'Market', 'Definition': 'π A regular gathering of people for the purchase and sale of goods.'},
{'Classification': 'Network', 'Definition': 'π A group of interconnected people, companies, or devices that share information or resources.'},
]
df_strategy = pd.DataFrame(strategy_data)
st.dataframe(df_strategy)
# ------------------------- AI DATA -------------------------
ai_data = {'accuracy': 0.89, 'precision': 0.72, 'recall': 0.64, 'f1': 0.68}
st.write(f"{AI} I'm sorry Dave, I'm afraid I can't do that.")
st.dataframe(pd.DataFrame(ai_data, index=['Model']))
# ------------------------- ONE-LINER FUNCTIONS -------------------------
st.table(pd.DataFrame(ai_data, index=['Model']))
st.json({'foo':'bar', 'fu':'ba', 'ai_data': ai_data})
st.metric(label="Model Accuracy", value=ai_data['accuracy'], delta=0.02)
st.button('Hit me ' + random.choice(EMOJIS))
st.checkbox('Tickle me ' + random.choice(EMOJIS))
st.radio('Choose your favorite ' + DATA, ['Bar chart', 'Pie chart', 'Line chart'])
st.selectbox('Select your ' + DATA, ['Sales', 'Expenses', 'Profits'])
st.multiselect('Pick your favorite ' + DATA + 's', ['Revenue', 'Profit', 'Loss'])
st.slider('Slide to ' + DATA, min_value=0, max_value=10)
st.select_slider('Slide to select your favorite ' + DATA, options=[1,2,3,4])
st.text_input('Enter some ' + DATA)
st.number_input('Enter a random ' + DATA + ' value')
st.text_area('Type something ' + random.choice(EMOJIS) + ' here')
st.date_input('Choose a ' + random.choice(['start', 'end']) + ' ' + DATA + ' date')
st.time_input('What time is it? ' + random.choice(EMOJIS))
st.file_uploader('Upload your favorite ' + DATA + ' ' + random.choice(EMOJIS))
st.color_picker('Pick a ' + DATA + ' ' + random.choice(EMOJIS))
|