williambr commited on
Commit
4ce0f80
1 Parent(s): 0909a51

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -25
app.py CHANGED
@@ -12,31 +12,34 @@ st.title("Input a city and state I'll take you there! - Ex. Mound, MN")
12
 
13
  city_and_state_string = st.text_input("Please search for a city:")
14
 
15
- if city_and_state_string != "":
16
-
17
- split_city_state = city_and_state_string.split(", ")
18
- state_name = split_city_state[1]
19
- city_name = split_city_state[0]
20
-
21
- #create a dataframe consisting of the correct city input
22
- city_df = df[df["City"] == city_name]
23
-
24
-
25
- #use the city dateframe to confirm you are using the right map
26
- lat = city_df[city_df["State"] == state_name]["Latitude"].values[0]
27
- lon = city_df[city_df["State"] == state_name]["Longitude"].values[0]
28
- zipCode = city_df[city_df["State"] == state_name]["Zip"].values[0]
29
- city_list = []
30
- lat_list = []
31
- long_list = []
32
-
33
-
34
- city_list.append(city_name)
35
- lat_list.append(lat)
36
- long_list.append(lon)
37
- st.map(pd.DataFrame({'cities' : city_list, 'lat' : lat_list, 'lon' : long_list}))
38
- st.write(city_name, "is located at: ", lat, ",", lon)
39
- st.write("The zip code is: ", zipCode)
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
 
 
12
 
13
  city_and_state_string = st.text_input("Please search for a city:")
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
+ try:
17
+ if city_and_state_string != "":
18
+
19
+ split_city_state = city_and_state_string.split(", ")
20
+ state_name = split_city_state[1]
21
+ city_name = split_city_state[0]
22
+
23
+ #create a dataframe consisting of the correct city input
24
+ city_df = df[df["City"] == city_name]
25
+
26
+
27
+ #use the city dateframe to confirm you are using the right map
28
+ lat = city_df[city_df["State"] == state_name]["Latitude"].values[0]
29
+ lon = city_df[city_df["State"] == state_name]["Longitude"].values[0]
30
+ zipCode = city_df[city_df["State"] == state_name]["Zip"].values[0]
31
+ city_list = []
32
+ lat_list = []
33
+ long_list = []
34
+
35
+
36
+ city_list.append(city_name)
37
+ lat_list.append(lat)
38
+ long_list.append(lon)
39
+ st.map(pd.DataFrame({'cities' : city_list, 'lat' : lat_list, 'lon' : long_list}))
40
+ st.write(city_name, "is located at: ", lat, ",", lon)
41
+ st.write("The zip code is: ", zipCode)
42
+ except:
43
+ st.write("Did you misspell something?")
44
 
45