Spaces:
Runtime error
Runtime error
Update app.py
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950#import definitionsimport pandas as pdimport streamlit as stdf = pd.read_csv('Map-City-State-Zip-Lat-Long.txt', dtype=str, sep=';')df["Latitude"] = df["Latitude"].astype(float)df["Longitude"] = df["Longitude"].astype(float)st.title("Input a city and state I'll take you there! - Ex. Boston, MA")city_and_state_string = st.text_input("Please search for a city:")try:if city_and_state_string != "":split_city_state = city_and_state_string.split(", ")state_name = split_city_state[1]city_name = split_city_state[0]#create a dataframe consisting of the correct city inputcity_df = df[df["City"] == city_name]#use the city dateframe to confirm you are using the right maplat = city_df[city_df["State"] == state_name]["Latitude"].values[0]lon = city_df[city_df["State"] == state_name]["Longitude"].values[0]#zipCode = city_df[city_df["State"] == state_name]["Zip"].values[0]city_list = []lat_list = []long_list = []city_list.append(city_name)lat_list.append(lat)long_list.append(lon)st.map(pd.DataFrame({'cities' : city_list, 'lat' : lat_list, 'lon' : long_list}))st.write(city_name, "is located at: ", lat, ",", lon)#st.write("The zip code is: ", zipCode)st.write("Would you like to save this location?")save_button = st.button("Save")if save_button:st.write("Saved!")except:st.write("Try Again")123456789101112131415161718192021222324252627282930313233343536373839404142434445464748#import definitions#from tkinter import Wimport pandas as pdimport streamlit as stimport gradio as gr#cleaning datadf = pd.read_csv('Map-City-State-Zip-Lat-Long.txt', dtype=str, sep=';')df["Latitude"] = df["Latitude"].astype(float)df["Longitude"] = df["Longitude"].astype(float)def writeToDataFrame(dataframe, name, location, latitude, longitude):newdf = {'Name': name, 'Location': location, 'Latitude': latitude, 'Longitude': longitude}dataframe = dataframe.append(newdf, ignore_index = True)return dataframest.title("Input a city and state I'll take you there! - Ex. Boston, MA")city_and_state_string = st.text_input("Please search for a location:")if city_and_state_string != "":split_city_state = city_and_state_string.split(", ")state_name = split_city_state[1]city_name = split_city_state[0]#create a dataframe consisting of the correct city inputcity_df = df[df["City"] == city_name]#use the city dateframe to confirm you are using the right maplat = city_df[city_df["State"] == state_name]["Latitude"].values[0]lon = city_df[city_df["State"] == state_name]["Longitude"].values[0]city_list = []lat_list = []long_list = []city_list.append(city_name)lat_list.append(lat)long_list.append(lon)st.map(pd.DataFrame({'cities' : city_list, 'lat' : lat_list, 'lon' : long_list}))checkbox = st.checkbox("Show/Hide Latitude/Longitude")if checkbox:st.write(city_name, "is located at: ", lat, ",", lon)
app.py+34-36