File size: 1,001 Bytes
a76c6ff
 
 
 
 
 
 
596f588
a76c6ff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#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. 

import streamlit as st
import pandas as pd
import numpy as np

# load dataset
quotes_data = pd.read_csv('quotes.csv', index_col=0)

# display random list of ten quotes
st.title('Famous Quotes Generator')
st.write('Generate a random list of ten famous quotes!')

# generate random list
random_list = np.random.choice(quotes_data.index.values, 10, replace=False)
random_quotes = quotes_data.loc[random_list]

# display random list
st.table(random_quotes)

# give user button to regenerate random list
if st.button('Regenerate Quotes'):
    random_list = np.random.choice(quotes_data.index.values, 10, replace=False)
    random_quotes = quotes_data.loc[random_list]
    st.table(random_quotes)