Ejemplo n.º 1
0
 def test_to_datetime_coerce(self):
     """ensure to_datetime returns only numerics with coerce default"""
     Conv = self.create_ColumnConversions_class(
         make_dirty_datetime_dataframe())
     Conv.to_datetime(keycol)
     assert False not in [
         isinstance(val, np.datetime64) for val in Conv.df[keycol].values
     ]
Ejemplo n.º 2
0
 def test_check_datetime(self):
     """ensure check_datetime returns value counts for all errors"""
     Conv = self.create_ColumnConversions_class(
         make_dirty_datetime_dataframe())
     value_count_series = Conv.check_datetime(keycol)
     value_test = np.array(datetime_dirt_list[1:]).astype(str)
     self.assertCountEqual(
         value_count_series.index.values.astype(str),
         value_test,
     )
Ejemplo n.º 3
0
 def test_to_datetime_coerce_false(self):
     """ensure to_datetime returns non-numeric values with coerce=False"""
     Conv = self.create_ColumnConversions_class(
         make_dirty_datetime_dataframe())
     Conv.to_datetime(keycol, coerce=False)
     value_count_series = Conv.check_datetime(keycol)
     value_test = np.array(datetime_dirt_list[1:]).astype(str)
     self.assertCountEqual(
         value_count_series.index.values.astype(str),
         value_test,
     )
     self.assertIsInstance(Conv.df[keycol].values[0], str)
Ejemplo n.º 4
0
 def test_inplace_return_series_inplace(self):
     """ensure inplace_return_series makes inplace changes"""
     df = make_dirty_numeric_dataframe()
     series = make_dirty_datetime_dataframe()[keycol]
     series_test = inplace_return_series(
         df,
         keycol,
         series,
         inplace=True,
         return_series=False,
     )
     self.assertIsNone(series_test)
     self.assertSequenceEqual(df[keycol].values.tolist(),
                              series.values.tolist())
Ejemplo n.º 5
0
 def test_inplace_return_series_return(self):
     """ensure inplace_return_series returns series"""
     df = make_dirty_numeric_dataframe()
     series_original = df[keycol]
     series = make_dirty_datetime_dataframe()[keycol]
     series_test = inplace_return_series(
         df,
         keycol,
         series,
         inplace=False,
         return_series=True,
     )
     self.assertSequenceEqual(series.values.tolist(),
                              series_test.values.tolist())
     self.assertSequenceEqual(df[keycol].values.tolist(),
                              series_original.values.tolist())
Ejemplo n.º 6
0
 def test_inplace_return_series_inplace_target_col(self):
     """ensure inplace_return_series makes inplace changes to target_col"""
     df = make_dirty_numeric_dataframe()
     series_original = df[keycol]
     series_target = make_dirty_datetime_dataframe()[keycol]
     target_column = 'test_target'
     series_test = inplace_return_series(df,
                                         keycol,
                                         series_target,
                                         inplace=True,
                                         return_series=False,
                                         target_column=target_column)
     self.assertIsNone(series_test)
     self.assertSequenceEqual(df[keycol].values.tolist(),
                              series_original.values.tolist())
     self.assertSequenceEqual(df[target_column].values.tolist(),
                              series_target.values.tolist())