示例#1
0
 def test_transform_doy_fmt_list(self):
     df = pd.DataFrame(
         {"date_column": ["2016-01-01", "2016-06-28", "2016-07-28"]})
     trainable = Map(columns=[day_of_year(it.date_column, "%Y-%m-%d")])
     trained = trainable.fit(df)
     transformed_df = trained.transform(df)
     self.assertEqual(transformed_df["date_column"][0], 1)
     self.assertEqual(transformed_df["date_column"][1], 180)
     self.assertEqual(transformed_df["date_column"][2], 210)
示例#2
0
    def test_transform_doy_fmt_list(self):
        df = pd.DataFrame(
            {"date_column": ["2016-01-01", "2016-06-28", "2016-07-28"]})
        sdf = self.sqlCtx.createDataFrame(df)

        trainable = Map(columns=[day_of_year(it.date_column, "y-M-d")])
        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"], 180)
        self.assertEqual(transformed_df.collect()[2]["date_column"], 210)