def test_transform_hour_fmt_list(self): df = pd.DataFrame({ "date_column": [ "2016-01-01 15:16:45", "2016-06-28 12:18:51", "2016-07-28 01:01:01", ] }) trainable = Map(columns=[hour(it.date_column, "%Y-%m-%d %H:%M:%S")]) trained = trainable.fit(df) transformed_df = trained.transform(df) self.assertEqual(transformed_df["date_column"][0], 15) self.assertEqual(transformed_df["date_column"][1], 12) self.assertEqual(transformed_df["date_column"][2], 1)
def test_transform_hour_fmt_list(self): df = pd.DataFrame({ "date_column": [ "2016-01-01 15:16:45", "2016-06-28 12:18:51", "2016-07-28 01:01:01", ] }) sdf = self.sqlCtx.createDataFrame(df) trainable = Map(columns=[hour(it.date_column, "y-M-d HH:mm:ss")]) trained = trainable.fit(sdf) transformed_df = trained.transform(sdf) self.assertEqual(transformed_df.collect()[0]["date_column"], 15) self.assertEqual(transformed_df.collect()[1]["date_column"], 12) self.assertEqual(transformed_df.collect()[2]["date_column"], 1)