From c56c2c3525155b58e83ac051c1a674476163e746 Mon Sep 17 00:00:00 2001 From: amlrelsa-ms Date: Fri, 24 Sep 2021 21:40:44 +0000 Subject: [PATCH] update samples from Release-112 as a part of SDK release --- .../scripts/prepdata/normalize.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/how-to-use-azureml/machine-learning-pipelines/nyc-taxi-data-regression-model-building/scripts/prepdata/normalize.py b/how-to-use-azureml/machine-learning-pipelines/nyc-taxi-data-regression-model-building/scripts/prepdata/normalize.py index 589fd297..8ac62bc1 100644 --- a/how-to-use-azureml/machine-learning-pipelines/nyc-taxi-data-regression-model-building/scripts/prepdata/normalize.py +++ b/how-to-use-azureml/machine-learning-pipelines/nyc-taxi-data-regression-model-building/scripts/prepdata/normalize.py @@ -28,13 +28,21 @@ replaced_distance_vals_df = (replaced_stfor_vals_df.replace({"distance": ".00"}, normalized_df = replaced_distance_vals_df.astype({"distance": 'float64'}) + +def time_to_us(time_str): + hh, mm , ss = map(int, time_str.split(':')) + return (ss + 60 * (mm + 60 * hh)) * (10**6) + + temp = pd.DatetimeIndex(normalized_df["pickup_datetime"]) -normalized_df["pickup_date"] = temp.date +normalized_df["pickup_date"] = pd.to_datetime(temp.date) normalized_df["pickup_time"] = temp.time +normalized_df["pickup_time"] = normalized_df["pickup_time"].apply(lambda x: time_to_us(str(x))) temp = pd.DatetimeIndex(normalized_df["dropoff_datetime"]) -normalized_df["dropoff_date"] = temp.date +normalized_df["dropoff_date"] = pd.to_datetime(temp.date) normalized_df["dropoff_time"] = temp.time +normalized_df["dropoff_time"] = normalized_df["dropoff_time"].apply(lambda x: time_to_us(str(x))) del normalized_df["pickup_datetime"] del normalized_df["dropoff_datetime"]