Skip to content

Commit

Permalink
refactor(ir): remove deprecated Schema.apply_to() method
Browse files Browse the repository at this point in the history
This logic has been moved to the `ibis.formats.pandas` module.

BREAKING CHANGE: `Schema.apply_to()` is removed, use `ibis.formats.pandas.PandasConverter.convert_frame()` instead
  • Loading branch information
kszucs authored and cpcloud committed Mar 27, 2024
1 parent 364a6ee commit 06962b2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
12 changes: 1 addition & 11 deletions ibis/expr/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
from ibis.common.exceptions import InputTypeError, IntegrityError
from ibis.common.grounds import Concrete
from ibis.common.patterns import Coercible
from ibis.util import deprecated, indent
from ibis.util import indent

if TYPE_CHECKING:
import pandas as pd
from typing_extensions import TypeAlias


Expand Down Expand Up @@ -224,15 +223,6 @@ def name_at_position(self, i: int) -> str:
"""
return self.names[i]

@deprecated(
as_of="6.0",
instead="use ibis.formats.pandas.PandasConverter.convert_frame() instead",
)
def apply_to(self, df: pd.DataFrame) -> pd.DataFrame:
from ibis.formats.pandas import PandasData

return PandasData.convert_table(df, self)


SchemaLike: TypeAlias = Union[
Schema,
Expand Down
17 changes: 0 additions & 17 deletions ibis/expr/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import NamedTuple

import numpy as np
import pandas.testing as tm
import pyarrow as pa
import pytest

Expand Down Expand Up @@ -180,22 +179,6 @@ def df():
return pd.DataFrame({"A": pd.Series([1], dtype="int8"), "b": ["x"]})


def test_apply_to_column_rename(df):
schema = sch.Schema({"a": "int8", "B": "string"})
expected = df.rename({"A": "a", "b": "B"}, axis=1)
with pytest.warns(FutureWarning):
df = schema.apply_to(df.copy())
tm.assert_frame_equal(df, expected)


def test_apply_to_column_order(df):
schema = sch.Schema({"a": "int8", "b": "string"})
expected = df.rename({"A": "a"}, axis=1)
with pytest.warns(FutureWarning):
new_df = schema.apply_to(df.copy())
tm.assert_frame_equal(new_df, expected)


def test_api_accepts_schema_objects():
s1 = sch.schema(dict(a="int", b="str"))
s2 = sch.schema(s1)
Expand Down

0 comments on commit 06962b2

Please sign in to comment.