Example #1
0
    def test_validation(self):
        out = replace_missing_number(table=df_example2, group_by=['grp'], input_cols=['num2'], fill_method='ffill')
        print(out['out_table'])
        with self.assertRaises(BrighticsFunctionException) as bfe:
            out = replace_missing_number(table=df_example2, group_by=['grp'], fill_method='ffill')

        test_errors = bfe.exception.errors
        self.assertTrue({'0033':['input_cols']} in test_errors)
Example #2
0
 def test_validation(self):
     out = replace_missing_number(table=df_example2,
                                  group_by=['grp'],
                                  input_cols=['num2'],
                                  fill_method='ffill')
     print(out['out_table'])
     out = replace_missing_number(table=df_example2,
                                  group_by=['grp'],
                                  fill_method='ffill')
     print(out['out_table'])
Example #3
0
 def test_temp(self):
     d = df_example2['num2']
     out1 = replace_missing_number(table=df_example2, input_cols=['num2'], fill_value='mean')
     print(out1['out_table'])
     out2 = replace_missing_number(table=df_example2, input_cols=['num2', 'num3'], fill_value='median')
     print(out2['out_table'])
     out3 = replace_missing_number(table=df_example2, input_cols=[], fill_method='ffill')
     print(out3['out_table'])
     out4 = replace_missing_number(table=df_example2, input_cols=None, fill_method='bfill')
     print(out4['out_table'])
Example #4
0
 def test3(self):
     input_table = self.input_df
     input_cols = ['A', 'B', 'E']
     target_number = 1230
     target_string = 'null'
     func = replace_missing_number(table=input_table, input_cols=input_cols, fill_value_to=target_number, limit=1)
     print(func['out_table'])
     print(func['out_table'].dtypes)
     func = replace_missing_string(table=input_table, input_cols=input_cols, fill_string=target_string, limit=1)
     print(func['out_table'])
     print(func['out_table'].dtypes)
Example #5
0
 def test(self):
     input_table = self.input_df
     input_cols = ['A', 'B', 'E']
     target_number = 1230
     func = replace_missing_number(table=input_table,
                                   input_cols=input_cols,
                                   fill_value_to=target_number,
                                   limit=1)
     np.testing.assert_almost_equal(func['out_table']['A'].values,
                                    np.array([1230.0, 3.0, np.nan, np.nan]),
                                    10)
     np.testing.assert_almost_equal(func['out_table']['B'].values,
                                    np.array([2.0, 4.0, 1230.0, 3.0]), 10)
     np.testing.assert_almost_equal(
         func['out_table']['C'].values,
         np.array([np.nan, np.nan, np.nan, np.nan]), 10)
     np.testing.assert_almost_equal(func['out_table']['D'].values,
                                    np.array([0, 1, 5, 4]), 10)
     np.testing.assert_equal(func['out_table']['E'].values,
                             np.array(['A', 'B', 'C', None]), 10)