text_html_output_1.png
from matplotlib import pyplot

import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

train = pd.read_csv('/kaggle/input/nyc-taxi-trip-duration/train.zip')
test = pd.read_csv('/kaggle/input/nyc-taxi-trip-duration/test.zip')

EARTH_RADIUS = 6378.137
def haversine(xy1, xy2):
    return 2 * EARTH_RADIUS * np.arcsin(np.sqrt(np.sin((xy2[:, 0] - xy1[:, 0]) / 2) ** 2 + np.cos(xy1[:, 0]) * np.cos(xy2[:, 0]) * np.sin((xy2[:, 1] - xy2[:, 1]) / 2)))
train['distance'] = haversine(np.radians(train[['pickup_longitude', 'pickup_latitude']].values), np.radians(train[['dropoff_longitude', 'dropoff_latitude']].values))
test['distance'] = haversine(np.radians(test[['pickup_longitude', 'pickup_latitude']].values), np.radians(test[['dropoff_longitude', 'dropoff_latitude']].values))
pyplot.hist(np.log(train['distance'] + 1e-05), bins=50)