Spaces:
Runtime error
Runtime error
| #import definitions | |
| import pandas as pd | |
| import streamlit as st | |
| df = 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. Mound, MN") | |
| city = st.text_input("Please search for a city:") | |
| if city != "": | |
| split_city_state = city.split(", ") | |
| state_name = split_city_state[1] | |
| city_name = split_city_state[0] | |
| #create a dataframe consisting of the correct city input | |
| city_df = df[df["City"] == city_name] | |
| #use the city dateframe to confirm you are using the right map | |
| lat = 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) | |