def test_transform_month_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=[month(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], 1) self.assertEqual(transformed_df["date_column"][1], 6) self.assertEqual(transformed_df["date_column"][2], 7)
def test_transform_month_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=[month(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"], 1) self.assertEqual(transformed_df.collect()[1]["date_column"], 6) self.assertEqual(transformed_df.collect()[2]["date_column"], 7)