示例#1
0
    def test_bad_home_team_colname_produces_error(self):
        input_df = pd.DataFrame({"blahblahblah": ["a", "a", "a"],
                                 "offense_team": ["a", "b", "a"]})
        ciow = preprocessing.ComputeIfOffenseIsHome("offense_team", "home_team")
        ciow.fit(input_df)

        with pytest.raises(KeyError):
            ciow.transform(input_df)
示例#2
0
 def test_correct_answer_without_copy(self):
     input_df = pd.DataFrame({"home_team": ["a", "a", "a"],
                              "offense_team": ["a", "b", "a"]})
     expected_transformed_df = pd.DataFrame({"home_team": ["a", "a", "a"],
                              "offense_team": ["a", "b", "a"],
                              "offense_home_team": [True, False, True]})
     ciow = preprocessing.ComputeIfOffenseIsHome("offense_team", "home_team",
                                              offense_home_team_colname="offense_home_team",
                                              copy=False)
     ciow.transform(input_df)
     pd.util.testing.assert_frame_equal(input_df.sort_index(axis=1), expected_transformed_df.sort_index(axis=1))