text_html_output_1.png
from geopy import distance

import pandas as pd

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

df = pd.read_csv('/kaggle/input/yourcabs/YourCabs_training.csv')

df.shape

data = df.drop(['Car_Cancellation', 'Cost_of_error'], axis=1)
target = df[['Car_Cancellation']]

data.isnull().mean()

data = data.drop(['id', 'user_id', 'package_id', 'to_area_id', 'from_city_id', 'to_city_id', 'to_date'], axis=1)

data.shape

data = data.drop(['vehicle_model_id'], axis=1)

traveltype = pd.get_dummies(data['travel_type_id'], drop_first=True)

data = pd.concat([data, traveltype], axis=1)
data = data.drop(['travel_type_id'], axis=1)

data.rename(columns={2: 'traveltype_pointtopoint', 3: 'traveltype_hourly'}, inplace=True)

def cal_distance(from_lat, from_long, to_lat, to_long):
    return distance.distance((from_lat, from_long), (to_lat, to_long)).km

data['distance'] = data.apply(lambda row: cal_distance(row['from_lat'], row['from_long'], row['to_lat'], row['to_long']), axis=1)

data = data.drop(['from_lat', 'from_long', 'to_lat', 'to_long'], axis=1)

data[data['time_diff'] < 0].head()