def test_find_replace7(): testing_df = df.copy() testing_df['col4'] = pd.Series(['hello', 'world', 'wild'], index = [0, 1, 2]) result_df = testing_df.copy() clean.findReplace(result_df, 3, [".*"], ['hello'], True) testing_df['col4'].replace(to_replace='.*', value='hello', regex=True, inplace=True) assert (((testing_df.fillna(0) == result_df.fillna(0)).all()).all()) == True
def test_find_replace6(): testing_df = df.copy() result_df = df.copy() clean.findReplace(result_df, 0, ["[0-9]+\.?[0-9]*"], [32], True) testing_df['col1'].replace(to_replace='[0-9]+\.?[0-9]*', value='32', regex=True, inplace=True) result_df = result_df.astype(float) assert (((testing_df.fillna(0) == result_df.fillna(0)).all()).all()) == True
def test_find_replace1(): testing_df = df.copy() result_df = df.copy() clean.findReplace(result_df, 0, [2], [8], False) testing_df['col1'].replace(to_replace=2, value=8, regex=False, inplace=True) result_df = result_df.astype(float) assert (((testing_df.fillna(0) == result_df.fillna(0)).all()).all()) == True
def test_find_replace8(): testing_df = df.copy() with pytest.raises(Exception): clean.findReplace(testing_df, 30, [".*"], ['hello'], True)
def test_find_replace3(): testing_df = df.copy() result_df = df.copy() clean.findReplace(result_df, 0, [16], [32], False) result_df = result_df.astype(float) assert (((testing_df.fillna(0) == result_df.fillna(0)).all()).all()) == True