Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import pandas as pd | |
| import folium | |
| from streamlit_folium import folium_static | |
| def main(): | |
| st.title("Place Recommender System") | |
| st.write("Please enter your trip information below:") | |
| # use columns to display the inputs and map/recommendations side by side | |
| col1, col2 = st.columns(2) | |
| with col1: | |
| destination = st.text_input("Destination") | |
| category = st.selectbox("Category",('Beach', 'Market', 'Park', 'Tourist place', 'Temple', 'Museum', 'Cafe','Hotels ','Restaurants')) | |
| if st.button("Submit"): | |
| st.write(f"Destination: {destination}") | |
| st.write(f"Category: {category}") | |
| # load recommendations data | |
| recommendations = pd.read_csv('recommendations.csv') | |
| # filter recommendations based on user input | |
| filtered_recommendations = recommendations[(recommendations['Destination'] == destination) & | |
| (recommendations['Category'] == category)] | |
| # display recommendations on map | |
| map_center = filtered_recommendations[['Latitude', 'Longitude']].mean().values.tolist() | |
| my_map = folium.Map(location=map_center, zoom_start=12, tiles='OpenStreetMap') | |
| for _, row in filtered_recommendations.iterrows(): | |
| folium.Marker([row['Latitude'], row['Longitude']], | |
| popup=row['Name'], | |
| tooltip=row['Name']).add_to(my_map) | |
| with col2: | |
| st.write("Here are some recommendations on a map:") | |
| folium_static(my_map) | |
| # display recommendations in a list | |
| st.write("Here are some recommendations:") | |
| table = filtered_recommendations[['Name','Description','Reviews','Google Rating(out of 5)']] | |
| table_html = table.to_html(index=False, escape=False) | |
| st.write(table_html, unsafe_allow_html=True) | |
| if __name__ == "__main__": | |
| main() | |