Skip to content

Instantly share code, notes, and snippets.

View justinm0rgan's full-sized avatar

Justin Morgan Williams justinm0rgan

View GitHub Profile
@Francismorales
Francismorales / Google_PlacesAPI_address_search.py
Created May 19, 2020 04:23
This routine takes the street name and number of McDonalds restaurants and returns the full formatted address (zip code included) and the permanently closed variable from Google Maps Places API.
import pandas as pd
import requests
import json
addres_list = list(McDonalds_data['address']) #prepare variable to pass to URL
state_list = list(McDonalds_data['state']) #prepare variable to pass to URL
placesAPI_data = pd.DataFrame(columns=['formatted_address', 'name', 'permanently_closed']) #initialize dataframe
for i in range(len(addres_list)):
address = addres_list[i].replace(' ', '%20') #make sure there are no blank spaces for the URL
state = state_list[i]
@aerispaha
aerispaha / read_shapefile.py
Created January 14, 2017 19:09
Read a shapefile into a Pandas dataframe
def read_shapefile(shp_path):
"""
Read a shapefile into a Pandas dataframe with a 'coords' column holding
the geometry information. This uses the pyshp package
"""
import shapefile
#read file, parse out the records and shapes
sf = shapefile.Reader(shp_path)
fields = [x[0] for x in sf.fields][1:]