Spaces:
Sleeping
Sleeping
#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) |