def test_average_mode1(): testing_df = df.copy() result_df = df.copy() clean.fillWithAverage(testing_df, 1, 'mode') average = 2 result_df['col2'].fillna(value=average, inplace=True) assert (((testing_df.fillna(0) == result_df.fillna(0)).all()).all()) == True
def test_average_mode2(): testing_df = df.copy() testing_df['col4'] = pd.Series([2., 2., 3., 3.], index=[0, 1, 4, 5]) result_df = testing_df.copy() clean.fillWithAverage(testing_df, 3, 'mode') average = 2 result_df['col4'].fillna(value=average, inplace=True) assert (((testing_df.fillna(0) == result_df.fillna(0)).all()).all()) == True
def test_average_all3(): testing_df = df.copy() with pytest.raises(Exception): clean.fillWithAverage(testing_df, 10, 'mean')
def test_average_all2(): testing_df = df.copy() clean.fillWithAverage(testing_df, 2, 'mean') assert (((testing_df.fillna(0) == df.fillna(0)).all()).all()) == True