text_plain_output_1.png
import numpy as np

import pandas as pd

import warnings

import gc
import warnings
warnings.filterwarnings('ignore')
import scipy as sp
import numpy as np
import pandas as pd
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)
from tqdm.auto import tqdm
import itertools
from sklearn.preprocessing import StandardScaler, OrdinalEncoder, MinMaxScaler
from sklearn.metrics import roc_auc_score, roc_curve
import matplotlib.pyplot as plt

df_train = pd.read_csv('../input/amazon-train/delivery time.csv')
df_test = pd.read_csv('../input/amazon-train/delivery time Test.csv')
test_id = df_test['ID']
df_train = df_train.set_index('Source.Name.1')
df_test = df_test.set_index('Source.Name.1')
target = df_train['Time_taken (min)']

df_test.isna().sum()

cdata = pd.concat([df_train, df_test], axis=0)
cdata = cdata.sort_index()
cdata.replace('nan', np.nan, inplace=True)

cdata2 = cdata.copy()
cdata2.drop(['ID', 'Time_taken (min)', 'Order_Date'], axis=1, inplace=True)
cat_features = cdata2.select_dtypes('O').columns
numeric_features = cdata2.select_dtypes(np.number)
na_numeric_features = [feat for feat in numeric_features if feat in cdata2.loc[:, cdata2.isna().sum() > 0].columns]

cdata2.isna().sum()

for i in range(cdata.shape[0]):
    tmp = cdata2.loc[i, 'Time_Orderd']
    [hr, mint] = tmp.split(':', 2)
    hr = int(hr)
    mint = int(mint)
    mint = mint / 60
    cdata2.loc[i, 'Time_Orderd'] = hr + mint

for i in range(cdata.shape[0]):
    tmp = cdata2.loc[i, 'Time_Order_picked']
    [hr, mint] = tmp.split(':', 2)
    hr = int(hr)
    mint = int(mint)
    mint = mint / 60
    cdata2.loc[i, 'Time_Order_picked'] = hr + mint

import geopy.distance
for i in range(0, cdata2.shape[0]):
    cdata2.loc[i, 'distance'] = geopy.distance.geodesic((cdata2.loc[i, 'Restaurant_latitude'], cdata2.loc[i, 'Restaurant_longitude']), (cdata2.loc[i, 'Delivery_location_latitude'], cdata2.loc[i, 'Delivery_location_longitude'])).km

cdata2.drop(['Restaurant_latitude', 'Restaurant_longitude', 'Delivery_location_longitude', 'Delivery_location_latitude', 'Delivery_person_ID'], axis=1, inplace=True)

cdata2