def test_drop_to(self): df = data.df_diamonds[["x", "y", "z"]] self.assertTrue( df.equals(data.df_diamonds >> gr.tf_drop(gr.columns_to("x")))) self.assertTrue( df.equals(data.df_diamonds >> gr.tf_drop(gr.columns_to(X.x)))) self.assertTrue( df.equals(data.df_diamonds >> gr.tf_drop(gr.columns_to(7))))
def drop_through(self): df = data.df_diamonds[["y", "z"]] self.assertTrue( df.equals(data.df_diamonds >> gr.tf_drop( gr.columns_to("x", inclusive=True)))) self.assertTrue( df.equals(data.df_diamonds >> gr.tf_drop( gr.columns_to(X.x, inclusive=True)))) self.assertTrue( df.equals(data.df_diamonds >> gr.tf_drop( gr.columns_to(7, inclusive=True))))
def test_drop_from(self): df = data.df_diamonds[["carat", "cut"]] self.assertTrue( df.equals( data.df_diamonds >> gr.tf_drop(gr.columns_from("color")))) self.assertTrue( df.equals( data.df_diamonds >> gr.tf_drop(gr.columns_from(X.color)))) self.assertTrue( df.equals(data.df_diamonds >> gr.tf_drop(gr.columns_from(2)))) self.assertTrue(data.df_diamonds[[]].equals( data.df_diamonds >> gr.tf_drop(gr.columns_from(0))))
def test_drop_between(self): df = data.df_diamonds[["carat", "z"]] self.assertTrue( df.equals(data.df_diamonds >> gr.tf_drop( gr.columns_between("cut", "y")))) self.assertTrue( df.equals( data.df_diamonds >> gr.tf_drop(gr.columns_between(X.cut, 8)))) df = data.df_diamonds[["carat", "cut"]] self.assertTrue( df.equals(data.df_diamonds >> gr.tf_drop( gr.columns_between(X.color, 20))))
def test_drop(self): df = data.df_diamonds.drop(["carat", "cut", "price"], axis=1) self.assertTrue( df.equals(data.df_diamonds >> gr.tf_drop("carat", "cut", "price"))) self.assertTrue(df.equals(data.df_diamonds >> gr.tf_drop(0, 1, 6))) self.assertTrue( df.equals(data.df_diamonds >> gr.tf_drop(0, 1, "price"))) self.assertTrue( df.equals(data.df_diamonds >> gr.tf_drop([0, X.cut], X.price))) self.assertTrue( df.equals( data.df_diamonds >> gr.tf_drop(X.carat, X["cut"], X.price))) self.assertTrue( df.equals( data.df_diamonds >> gr.tf_drop(X[["carat", "cut", "price"]]))) self.assertTrue( df.equals( data.df_diamonds >> gr.tf_drop(X[["carat", "cut"]], X.price))) self.assertTrue( df.equals(data.df_diamonds >> gr.tf_drop(X.iloc[:, [0, 1, 6]]))) self.assertTrue( df.equals(data.df_diamonds >> gr.tf_drop( [X.loc[:, ["carat", "cut", "price"]]])))
def test_drop_startswith(self): df = data.df_diamonds[["depth", "table", "price", "x", "y", "z"]] assert df.equals(data.df_diamonds >> gr.tf_drop(gr.starts_with("c")))
def test_drop_matches(self): df = data.df_diamonds[["depth", "table", "x", "y", "z"]] assert df.equals( data.df_diamonds >> gr.tf_drop(gr.matches("^c[auol]|p.i")))
def test_drop_containing(self): df = data.df_diamonds[["depth", "table", "x", "y", "z"]] assert df.equals(data.df_diamonds >> gr.tf_drop(gr.contains("c")))
def test_drop_endswith(self): df = data.df_diamonds.drop("z", axis=1) assert df.equals(data.df_diamonds >> gr.tf_drop(gr.ends_with("z")))