File size: 1,556 Bytes
d863e72
f461271
d34aea0
5dcdc61
5e2d822
5759e2a
 
 
81dff67
f8ca16c
301df3e
e133ffb
0909a51
6633d16
7616238
4ce0f80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5ae9424
 
 
4ce0f80
 
e133ffb
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#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_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 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)
        st.write("Would you like to save this location?")
        if st.button("Save")
            st.write("Saved!")
except: 
    st.write("Did you misspell something?")