Spaces:
Runtime error
Runtime error
#write a python streamlit quote generator with a famous quotes dataset. Load the quotes.csv dataset from a file. 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 with a search textbox and button with the default value for the quote search to be courage. if the search button is used perform a dataframe query on the set of quotes. If search is used allow retrieval of up to 1000 quotes that have the search keyword anywhere within the text of a single line from the csv file. | |
import streamlit as st | |
import pandas as pd | |
import numpy as np | |
# Load the dataset | |
quotes = pd.read_csv('quotes.csv', index_col=0) | |
# Start the Streamlit App | |
st.title('Quote Generator') | |
# Generate a random set of ten quotes | |
quotes_random = quotes.sample(10) | |
st.write(quotes_random) | |
# On the sidebar, give user a button to regenerate the random list of ten quotes | |
if st.button('Regenerate Quotes'): | |
quotes_random = quotes.sample(10) | |
st.write(quotes_random) | |
# Search textbox and button with the default value for the quote search to be courage | |
search_term = st.text_input(label='Search Term', value='courage') | |
if st.button('Search'): | |
quotes_search = quotes[quotes['text'].str.contains(search_term, case=False)].head(1000) | |
st.write(quotes_search) |