This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print('There are {} uniques categories.'.format(len(sf_venues['Venue Category'].unique()))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sf_venues.groupby('Neighborhood').count() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sf_venues = getNearbyVenues(names = sf_data['Neighborhood'], | |
latitudes = sf_data['Latitude'], | |
longitudes = sf_data['Longitude'] | |
) | |
sf_venues.head() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getNearbyVenues(names, latitudes, longitudes, radius=500): | |
venues_list=[] | |
for name, lat, lng in zip(names, latitudes, longitudes): | |
# create the API request URL | |
url = 'https://api.foursquare.com/v2/venues/explore?&client_id={}&client_secret={}&v={}&ll={},{}&radius={}&limit={}'.format( | |
CLIENT_ID, | |
CLIENT_SECRET, | |
VERSION, | |
lat, | |
lng, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
radius = 500 | |
LIMIT = 100 | |
url = 'https://api.foursquare.com/v2/venues/explore?client_id={}&client_secret={}&ll={},{}&v={}&radius={}&limit={}'.format(CLIENT_ID, CLIENT_SECRET, neighborhood_latitude, neighborhood_longitude, VERSION, radius, LIMIT) | |
results = requests.get(url).json() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
neighborhood_latitude = sf_data.loc[3, 'Latitude'] # neighborhood latitude value | |
neighborhood_longitude = sf_data.loc[3, 'Longitude'] # neighborhood longitude value | |
neighborhood_name = sf_data.loc[3, 'Neighborhood'] # neighborhood name | |
print('Latitude and longitude values of {} are {}, {}.'.format(neighborhood_name, | |
neighborhood_latitude, | |
neighborhood_longitude)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CLIENT_ID = 'YOUR_CLIENT_ID' # your Foursquare ID | |
CLIENT_SECRET = 'YOUR_CLIENT_SECRET' # your Foursquare Secret | |
VERSION = '20180605' # Foursquare API version | |
LIMIT = 100 | |
print('Your credentails:') | |
print('CLIENT_ID: ' + CLIENT_ID) | |
print('CLIENT_SECRET:' + CLIENT_SECRET) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map_sf = folium.Map(location = [latitude, longitude], zoom_start=10) | |
# add markers to map | |
for lat, lng, neighborhood in zip(sf_data['Latitude'], sf_data['Longitude'], sf_data['Neighborhood']): | |
label = '{}'.format(neighborhood) | |
label = folium.Popup(label, parse_html = True) | |
folium.CircleMarker( | |
[lat, lng], | |
radius = 5, | |
popup = label, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
address = 'San Francisco' | |
geolocator = Nominatim(user_agent = "san_francisco_explorer") | |
location = geolocator.geocode(address) | |
latitude = location.latitude | |
longitude = location.longitude | |
print('The geograpical coordinates of San Francisco are {}, {}.'.format(latitude, longitude)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!pip install uszipcode | |
from uszipcode import SearchEngine | |
search = SearchEngine(simple_zipcode=True) | |
latitude = [] | |
longitude = [] | |
for index, row in df1.iterrows(): | |
zipcode = search.by_zipcode(row["Zip Code"]).to_dict() |