import pandas as pd
import numpy as np
df = pd.read_csv("ch_postal_codes_utf8.csv")
print(df.shape)
print(df.columns)
print(df.head())
df["State"].value_counts()
df["City"].value_counts()
lat = np.array(df["Latitude"])
lng = np.array(df["Longitude"])
dlat = (lat[...,np.newaxis]-lat)*np.pi/180.
dlng = (lng[...,np.newaxis]-lng)*np.pi/180.
re = 6378.137 # The radius of Earth in km
d = 2*re*np.arcsin((np.sin(dlat*0.5)**2+np.cos(lat)*np.cos(lat[...,np.newaxis])*np.sin(dlng*0.5)**2)**0.5)
d.max()
d[d>0].min()
ix_gr = np.array(df[df["State Abbreviation"]=="GR"].index)
ix_zh = np.array(df[df["State Abbreviation"]=="ZH"].index)
d_grzh = d[ix_gr[...,np.newaxis],ix_zh]
d_grzh.min()
d_grzh.max()