<jupyter_start><jupyter_text>1. Define Client and fields<jupyter_code>gmaps = googlemaps.Client(key = API_KEY)
# defining the fields that we need to search for each ID
my_fields = ['name', 'permanently_closed']<jupyter_output><empty_output><jupyter_text>2. Getting the formatted address for each store<jupyter_code>priority_b = pd.read_excel('Priority A_B_C_3.0_cleansed.xlsx', sheet_name='Priority_B_799 stores')
priority_b
priority_b['Country'] = 'Canada'
priority_b['Formatted_address'] = priority_b['Name'] + ',' + priority_b['Street_Address'] + ',' + priority_b['City__Town'] + ',' + \
priority_b['Postal code'] + ',' + priority_b['Country']
priority_b.head()<jupyter_output><empty_output><jupyter_text>3. Getting the unique ID for each of the stores using geocode api<jupyter_code>priority_b['id'] = 'na'
priority_b_loa = priority_b['Formatted_address']
for address in priority_b_loa:
    try:
        priority_b.loc[priority_b['Formatted_address'] == address, ['id']] = gmaps.geocode(address)[0]['place_id']
        # set a buffer of 0.3 sec when running on google cloud
        time.sleep(0.3)
    except:
        break
priority_b.head()<jupyter_output><empty_output><jupyter_text>4. Filtering the permanently_closed lists<jupyter_code>priority_b['Permanently_closed'] = False
priority_b.head()
priority_b_id_loa = priority_b['id']
for id in priority_b_id_loa[:]:
    try:
        gmaps.place(place_id = id, fields = my_fields)['result']['permanently_closed']
        priority_b.loc[priority_b['id'] == id, ['Permanently_closed']] = True
    except:
        continue
priority_b.to_csv("priority_b_final.csv")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13487241798298907, 'fraction_numerical': 0.00850546780072904, 'mean_word_length': 6.160869565217391, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '70068', 'license': 'FTL', 'n_tokens_mistral': 589, 'n_tokens_neox': 581, 'n_words': 106, 'path': 'notebooks/Priority_B.ipynb', 'repo_name': 'allenren97/google_map_api', 'size': '1646'}