<jupyter_start><jupyter_text>1. Import Relevant Packages<jupyter_code>import pandas as pd
import requests
import os<jupyter_output><empty_output><jupyter_text>2. Load the Station File<jupyter_code>desktop = r'C:\Users\hlchang4.DS039047\Desktop'
station_location = pd.read_csv(os.path.join(desktop, 'station_location.csv'))<jupyter_output><empty_output><jupyter_text>3. Set the API key and Get the Latitudes and Longitudes<jupyter_code>api_key = "XXXXX"
station_location['station_full_name'] = station_location.apply(lambda row: row['Name']+' station, Hong Kong', axis=1)
station_location.head(10)
def get_lat_lon_from_api(address):
    api_response = requests.get('https://maps.googleapis.com/maps/api/geocode/json?address={0}&key={1}'.format(address, api_key))
    api_response_dict = api_response.json()
    latitude = api_response_dict['results'][0]['geometry']['location']['lat']
    longitude = api_response_dict['results'][0]['geometry']['location']['lng']
    return latitude, longitude
station_location_dict = {}

for index, row in station_location.iterrows():
    station_location_dict[row['Name']] = (get_lat_lon_from_api(row['station_full_name']))
station_location_dict<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14049586776859505, 'fraction_numerical': 0.014049586776859505, 'mean_word_length': 8.845528455284553, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 1, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '505439', 'license': 'MIT', 'n_tokens_mistral': 419, 'n_tokens_neox': 409, 'n_words': 62, 'path': 'Use_Google_Places_API_to_find_geoinformation_MTR_stations.ipynb', 'repo_name': 'bright1993ff66/Social-Media-Data-Analysis', 'size': '1210'}