williambr commited on
Commit
36cfca1
1 Parent(s): 4afd9cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -36
app.py CHANGED
@@ -1,50 +1,48 @@
1
  #import definitions
 
 
2
  import pandas as pd
3
  import streamlit as st
 
4
 
 
5
  df = pd.read_csv('Map-City-State-Zip-Lat-Long.txt', dtype=str, sep=';')
6
  df["Latitude"] = df["Latitude"].astype(float)
7
  df["Longitude"] = df["Longitude"].astype(float)
8
 
9
 
 
 
 
 
10
 
11
  st.title("Input a city and state I'll take you there! - Ex. Boston, MA")
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
- st.write("Would you like to save this location?")
43
- save_button = st.button("Save")
44
-
45
- if save_button:
46
- st.write("Saved!")
47
- except:
48
- st.write("Try Again")
49
 
50
 
 
1
  #import definitions
2
+ #from tkinter import W
3
+
4
  import pandas as pd
5
  import streamlit as st
6
+ import gradio as gr
7
 
8
+ #cleaning data
9
  df = pd.read_csv('Map-City-State-Zip-Lat-Long.txt', dtype=str, sep=';')
10
  df["Latitude"] = df["Latitude"].astype(float)
11
  df["Longitude"] = df["Longitude"].astype(float)
12
 
13
 
14
+ def writeToDataFrame(dataframe, name, location, latitude, longitude):
15
+ newdf = {'Name': name, 'Location': location, 'Latitude': latitude, 'Longitude': longitude}
16
+ dataframe = dataframe.append(newdf, ignore_index = True)
17
+ return dataframe
18
 
19
  st.title("Input a city and state I'll take you there! - Ex. Boston, MA")
20
+ city_and_state_string = st.text_input("Please search for a location:")
21
+
22
+ if city_and_state_string != "":
23
+
24
+ split_city_state = city_and_state_string.split(", ")
25
+ state_name = split_city_state[1]
26
+ city_name = split_city_state[0]
27
+
28
+ #create a dataframe consisting of the correct city input
29
+ city_df = df[df["City"] == city_name]
30
+
31
+ #use the city dateframe to confirm you are using the right map
32
+ lat = city_df[city_df["State"] == state_name]["Latitude"].values[0]
33
+ lon = city_df[city_df["State"] == state_name]["Longitude"].values[0]
34
+ city_list = []
35
+ lat_list = []
36
+ long_list = []
37
+ city_list.append(city_name)
38
+ lat_list.append(lat)
39
+ long_list.append(lon)
40
+
41
+ st.map(pd.DataFrame({'cities' : city_list, 'lat' : lat_list, 'lon' : long_list}))
42
+ checkbox = st.checkbox("Show/Hide Latitude/Longitude")
43
+
44
+ if checkbox:
 
 
 
45
  st.write(city_name, "is located at: ", lat, ",", lon)
46
+
 
 
 
 
 
 
 
47
 
48