awacke1 commited on
Commit
d22ed3d
Β·
1 Parent(s): d8d6502

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +109 -0
app.py CHANGED
@@ -100,3 +100,112 @@ st.date_input('Choose a ' + random.choice(['start', 'end']) + ' ' + DATA + ' dat
100
  st.time_input('What time is it? ' + random.choice(EMOJIS))
101
  st.file_uploader('Upload your favorite ' + DATA + ' ' + random.choice(EMOJIS))
102
  st.color_picker('Pick a ' + DATA + ' ' + random.choice(EMOJIS))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  st.time_input('What time is it? ' + random.choice(EMOJIS))
101
  st.file_uploader('Upload your favorite ' + DATA + ' ' + random.choice(EMOJIS))
102
  st.color_picker('Pick a ' + DATA + ' ' + random.choice(EMOJIS))
103
+
104
+
105
+ st.markdown("""
106
+
107
+ import streamlit as st
108
+ import pandas as pd
109
+ import random
110
+
111
+ # Magic commands
112
+ st.set_page_config(page_title='Streamlit Super Power Cheat Sheet - Gamified')
113
+ st.set_option('deprecation.showfileUploaderEncoding', False)
114
+
115
+ # Define player cards
116
+ player1 = [{'Word': 'Strategy', 'Definition': 'A plan of action designed to achieve a long-term or overall aim.'},
117
+ {'Word': 'Economics', 'Definition': 'The branch of knowledge concerned with the production, consumption, and transfer of wealth.'},
118
+ {'Word': 'Industry', 'Definition': 'Economic activity concerned with the processing of raw materials and manufacture of goods in factories.'}]
119
+
120
+ player2 = [{'Word': 'Manufacturing', 'Definition': 'The making of articles on a large scale using machinery.'},
121
+ {'Word': 'Transportation', 'Definition': 'The action of transporting someone or something or the process of being transported.'},
122
+ {'Word': 'Community', 'Definition': 'A group of people living in the same place or having a particular characteristic in common.'}]
123
+
124
+ # Create dataframes for each player card
125
+ df_player1 = pd.DataFrame(player1)
126
+ df_player2 = pd.DataFrame(player2)
127
+
128
+ # Merge the dataframes on word matches
129
+ df_matches = pd.merge(df_player1, df_player2, on='Word')
130
+
131
+ # Display the merged dataframe
132
+ st.dataframe(df_matches)
133
+
134
+ # Display the word match count
135
+ match_count = df_matches.shape[0]
136
+ st.write(f'Number of word matches: {match_count}')
137
+
138
+ # Display a random word match
139
+ if match_count > 0:
140
+ random_match = df_matches.iloc[random.randint(0, match_count-1)]
141
+ st.write(f'Random match: {random_match["Word"]}')
142
+ st.write(f'{random_match["Definition_x"]}')
143
+ st.write(f'{random_match["Definition_y"]}')
144
+ else:
145
+ st.write('No word matches')
146
+
147
+ # Emoji graphics
148
+ AI = 'πŸ€–'
149
+ DATA = 'πŸ“Š'
150
+ EMOJIS = ['🀣', 'πŸ˜‚', '😜', 'πŸ€ͺ', '😎', 'πŸ€”']
151
+
152
+ # strategy data
153
+ import pandas as pd
154
+
155
+ # Define the strategy classifications and their definitions
156
+ strategy_data = [
157
+ {'Classification': 'Economic', 'Definition': 'πŸ’° The branch of knowledge concerned with the production, consumption, and transfer of wealth.'},
158
+ {'Classification': 'Industry', 'Definition': '🏭 Economic activity concerned with the processing of raw materials and manufacture of goods in factories.'},
159
+ {'Classification': 'Manufacturing', 'Definition': '🏭 The making of articles on a large scale using machinery.'},
160
+ {'Classification': 'Development', 'Definition': 'πŸ—οΈ The process of growth, progress, or realization of goals.'},
161
+ {'Classification': 'Transport', 'Definition': 'πŸš— The movement of people, goods, or materials from one place to another.'},
162
+ {'Classification': 'Income', 'Definition': 'πŸ’Έ The money received by a person, company, or country for work, services, or investment.'},
163
+ {'Classification': 'Market', 'Definition': 'πŸ“ˆ A regular gathering of people for the purchase and sale of goods.'},
164
+ {'Classification': 'Network', 'Definition': '🌐 A group of interconnected people, companies, or devices that share information or resources.'},
165
+ ]
166
+
167
+ st.markdown("""
168
+ Classification Definition
169
+ 0 Economic πŸ’° The branch of knowledge concerned with the p...
170
+ 1 Industry 🏭 Economic activity concerned with the process...
171
+ 2 Manufacturing 🏭 The making of articles on a large scale usin...
172
+ 3 Development πŸ—οΈ The process of growth, progress, or realiz...
173
+ 4 Transport πŸš— The movement of people, goods, or materials ...
174
+ 5 Income πŸ’Έ The money received by a person, company, or ...
175
+ 6 Market πŸ“ˆ A regular gathering of people for the purcha...
176
+ 7 Network 🌐 A group of interconnected people, companies,...
177
+ """)
178
+
179
+ # Create a dataframe from the strategy data
180
+ df_strategy = pd.DataFrame(strategy_data)
181
+
182
+ # Display the dataframe
183
+ print(df_strategy)
184
+
185
+
186
+ # Example AI data
187
+ ai_data = {'accuracy': 0.89, 'precision': 0.72, 'recall': 0.64, 'f1': 0.68}
188
+
189
+ # One-liner functions
190
+ st.write(f"{AI} I'm sorry Dave, I'm afraid I can't do that.")
191
+ st.dataframe(pd.DataFrame(ai_data, index=['Model']))
192
+ st.table(pd.DataFrame(ai_data, index=['Model']))
193
+ st.json({'foo':'bar', 'fu':'ba', 'ai_data': ai_data})
194
+ st.metric(label="Model Accuracy", value=ai_data['accuracy'], delta=0.02)
195
+ st.button('Hit me ' + random.choice(EMOJIS))
196
+ st.checkbox('Tickle me ' + random.choice(EMOJIS))
197
+ st.radio('Choose your favorite ' + DATA, ['Bar chart', 'Pie chart', 'Line chart'])
198
+ st.selectbox('Select your ' + DATA, ['Sales', 'Expenses', 'Profits'])
199
+ st.multiselect('Pick your favorite ' + DATA + 's', ['Revenue', 'Profit', 'Loss'])
200
+ st.slider('Slide to ' + DATA, min_value=0, max_value=10)
201
+ st.select_slider('Slide to select your favorite ' + DATA, options=[1,2,3,4])
202
+ st.text_input('Enter some ' + DATA)
203
+ st.number_input('Enter a random ' + DATA + ' value')
204
+ st.text_area('Type something ' + random.choice(EMOJIS) + ' here')
205
+ st.date_input('Choose a ' + random.choice(['start', 'end']) + ' ' + DATA + ' date')
206
+ st.time_input('What time is it? ' + random.choice(EMOJIS))
207
+ st.file_uploader('Upload your favorite ' + DATA + ' ' + random.choice(EMOJIS))
208
+ st.color_picker('Pick a ' + DATA + ' ' + random.choice(EMOJIS))
209
+
210
+
211
+ """)