<jupyter_start><jupyter_text>Python module/package imports for this chapter<jupyter_code>import math, json, collections, itertools
import numpy as np
import matplotlib.pyplot as pp
%matplotlib inline
from mpl_toolkits.basemap import Basemap
import geopy<jupyter_output><empty_output><jupyter_text>**March 2020 update**:* at 02:58 in the video: some versions of Basemap (such as 1.2.1) crash if `lat_0` is greater than 45 degrees. We change the code accordingly. Also, when coordinates end outside the map because a location is not visible, `world` returns `inf`, resulting in a `matplotlib` warning. We check for `inf` to avoid the warnings.    Code and data needed from previous videos List of olympic cities and years:<jupyter_code>cities = []
years = []

for game in open('games.txt','r'):
    words = game.split()
    
    city = ' '.join(words[:-1])
    year = words[-1].strip('()')

    cities.append(city)
    years.append(year)<jupyter_output><empty_output><jupyter_text>Geolocated olympic-city coordinates (from a JSON file):<jupyter_code>coordinates_by_city = json.load(open('coords.json','r'))
coordinates_by_city<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10831889081455806, 'fraction_numerical': 0.01386481802426343, 'mean_word_length': 5.6, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '582104', 'license': 'MIT', 'n_tokens_mistral': 384, 'n_tokens_neox': 370, 'n_words': 116, 'path': 'efficientPy/Exercise Files/chapter2/02_04/02_04_comprehensions_begin.ipynb', 'repo_name': 'IvanaEscobar/sandbox', 'size': '1154'}