def test_dropconstants(): """Test dropping of constants columns from dataframes""" df = pd.DataFrame(columns=["A", "B"], data=[[1, 1], [2, 1]]) assert "B" not in grid.drop_constant_columns(df) assert "A" in grid.drop_constant_columns(df) assert "B" in grid.drop_constant_columns(df, alwayskeep="B") assert "B" in grid.drop_constant_columns(df, alwayskeep=["B"])
def test_dropconstants(): """Test dropping of constants columns from dataframes""" df = pd.DataFrame(columns=["A", "B"], data=[[1, 1], [2, 1]]) assert "B" not in grid.drop_constant_columns(df) assert "A" in grid.drop_constant_columns(df) assert "B" in grid.drop_constant_columns(df, alwayskeep="B") assert "B" in grid.drop_constant_columns(df, alwayskeep=["B"]) with pytest.raises(TypeError): grid.drop_constant_columns(df, alwayskeep={"FOO"}) with pytest.raises(TypeError): grid.drop_constant_columns(df, alwayskeep=1) with pytest.raises(TypeError): grid.drop_constant_columns({}) assert grid.drop_constant_columns(pd.DataFrame()).empty