def test_impute_zero(self): df = pd.DataFrame([{"value": np.NaN}]) dataframe_functions.impute_dataframe_zero(df) self.assertEqual(list(df.value), [0]) df = pd.DataFrame([{"value": np.PINF}]) dataframe_functions.impute_dataframe_zero(df) self.assertEqual(list(df.value), [0]) df = pd.DataFrame([{"value": np.NINF}]) dataframe_functions.impute_dataframe_zero(df) self.assertEqual(list(df.value), [0]) df = pd.DataFrame([{"value": np.NINF}, {"value": np.NaN}, {"value": np.PINF}, {"value": 1}]) dataframe_functions.impute_dataframe_zero(df) self.assertEqual(list(df.value), [0, 0, 0, 1]) df = pd.DataFrame([{"value": np.NINF}, {"value": np.NaN}, {"value": np.PINF}, {"value": 1}]) df = df.astype(np.float64) df = dataframe_functions.impute_dataframe_zero(df) self.assertEqual(list(df.value), [0, 0, 0, 1]) df = pd.DataFrame([{"value": np.NINF}, {"value": np.NaN}, {"value": np.PINF}, {"value": 1}]) df = df.astype(np.float32) df = dataframe_functions.impute_dataframe_zero(df) self.assertEqual(list(df.value), [0, 0, 0, 1])
def test_impute_zero(self): df = pd.DataFrame([{"value": np.NaN}]) dataframe_functions.impute_dataframe_zero(df) self.assertEqual(list(df.value), [0]) df = pd.DataFrame([{"value": np.PINF}]) dataframe_functions.impute_dataframe_zero(df) self.assertEqual(list(df.value), [0]) df = pd.DataFrame([{"value": np.NINF}]) dataframe_functions.impute_dataframe_zero(df) self.assertEqual(list(df.value), [0]) df = pd.DataFrame([{"value": np.NINF}, {"value": np.NaN}, {"value": np.PINF}, {"value": 1}]) dataframe_functions.impute_dataframe_zero(df) self.assertEqual(list(df.value), [0, 0, 0, 1]) df = pd.DataFrame([{"value": np.NINF}, {"value": np.NaN}, {"value": np.PINF}, {"value": 1}]) df = df.astype(np.float64) df = dataframe_functions.impute_dataframe_zero(df) self.assertEqual(list(df.value), [0, 0, 0, 1]) df = pd.DataFrame([{"value": np.NINF}, {"value": np.NaN}, {"value": np.PINF}, {"value": 1}]) df = df.astype(np.float32) df = dataframe_functions.impute_dataframe_zero(df) self.assertEqual(list(df.value), [0, 0, 0, 1])