def test_colbyframefunc(): df = _some_df() cbf_stage = ColByFrameFunc('A==B', _are_a_b_equal) res_df = cbf_stage(df) assert res_df.columns.get_loc('A==B') == 2 assert res_df['A==B'][1] == True assert res_df['A==B'][2] == False assert res_df['A==B'][3] == False
def test_colbyframefunc_follow(): df = _some_df() cbf_stage = ColByFrameFunc( 'A==B', _are_a_b_equal, follow_column='A', func_desc='R') res_df = cbf_stage(df) assert res_df.columns.get_loc('A==B') == 1 assert res_df['A==B'][1] == True assert res_df['A==B'][2] == False assert res_df['A==B'][3] == False
def test_pipeline_error(time): """Test exceptions at pipeline level""" # test fit df = _test_df() func = lambda df: df['num1'] == df['num3'] pipeline = PdPipeline([ColByFrameFunc("Equality", func), ColDrop("B")]) with pytest.raises(PipelineApplicationError): pipeline.fit(df, verbose=True, time=time) # test transform df = _test_df() with pytest.raises(PipelineApplicationError): pipeline.transform(df, verbose=True, time=time) # test fit_transform df = _test_df() with pytest.raises(PipelineApplicationError): pipeline.fit_transform(df, verbose=True, time=time)
def test_colbyframefunc_error(): df = _some_df() cbf_stage = ColByFrameFunc('A==B', _are_a_c_equal) with pytest.raises(PipelineApplicationError): cbf_stage(df)