awacke1 commited on
Commit
a76c6ff
·
1 Parent(s): b90db06

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #write a python streamlit quote generator with a famous quotes dataset. Load the famous quotes dataset from a file in github. When the program starts generate a random set of ten quotes and show them to the user. On the streamlit sidebar give the user a button to regenerate the random list of ten quotes.
2
+
3
+ import streamlit as st
4
+ import pandas as pd
5
+ import numpy as np
6
+
7
+ # load dataset
8
+ quotes_data = pd.read_csv('https://raw.githubusercontent.com/mashapols/datasets/master/famous_quotes.csv', index_col=0)
9
+
10
+ # display random list of ten quotes
11
+ st.title('Famous Quotes Generator')
12
+ st.write('Generate a random list of ten famous quotes!')
13
+
14
+ # generate random list
15
+ random_list = np.random.choice(quotes_data.index.values, 10, replace=False)
16
+ random_quotes = quotes_data.loc[random_list]
17
+
18
+ # display random list
19
+ st.table(random_quotes)
20
+
21
+ # give user button to regenerate random list
22
+ if st.button('Regenerate Quotes'):
23
+ random_list = np.random.choice(quotes_data.index.values, 10, replace=False)
24
+ random_quotes = quotes_data.loc[random_list]
25
+ st.table(random_quotes)