From 5ed59086caae266ffdca0e838d9ceb665a63e7a7 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 12 Dec 2025 22:54:22 +0000 Subject: [PATCH 1/2] Add to_ibis() method to DataFrame and Series This commit adds a `to_ibis()` method to both `DataFrame` and `Series` classes. This method allows users to access the underlying Ibis expression (`_data`) for more advanced operations or interoperability with Ibis directly. Tests were added in `tests/test_to_ibis.py` to verify the functionality. --- leanframe/core/frame.py | 4 ++++ leanframe/core/series.py | 4 ++++ tests/test_to_ibis.py | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 tests/test_to_ibis.py diff --git a/leanframe/core/frame.py b/leanframe/core/frame.py index 10caf76..94ef66f 100644 --- a/leanframe/core/frame.py +++ b/leanframe/core/frame.py @@ -91,6 +91,10 @@ def to_pandas(self) -> pd.DataFrame: types_mapper=lambda type_: pd.ArrowDtype(type_) ) + def to_ibis(self) -> ibis_types.Table: + """Return the underlying Ibis expression.""" + return self._data + """ Dynamic Nested Data Handler for leanframe diff --git a/leanframe/core/series.py b/leanframe/core/series.py index e7cd0e8..c352caf 100644 --- a/leanframe/core/series.py +++ b/leanframe/core/series.py @@ -234,6 +234,10 @@ def to_pandas(self) -> pd.Series: types_mapper=lambda type_: pd.ArrowDtype(type_) ) + def to_ibis(self) -> ibis_types.Column: + """Return the underlying Ibis expression.""" + return self._data + def to_numpy(self) -> np.ndarray: """Return a numpy representation of the Series.""" return self.values diff --git a/tests/test_to_ibis.py b/tests/test_to_ibis.py new file mode 100644 index 0000000..5f3b0b7 --- /dev/null +++ b/tests/test_to_ibis.py @@ -0,0 +1,34 @@ + +import pytest +import pandas as pd +import leanframe as lf +import ibis +import ibis.expr.types as ibis_types +from leanframe.core.frame import DataFrame +from leanframe.core.series import Series + +def test_dataframe_to_ibis(): + # Setup + con = ibis.sqlite.connect() + t = con.create_table('test_df_ibis', schema=ibis.schema({'a': 'int64', 'b': 'string'})) + df = DataFrame(t) + + # Execute + expr = df.to_ibis() + + # Assert + assert isinstance(expr, ibis_types.Table) + assert expr.equals(t) + +def test_series_to_ibis(): + # Setup + con = ibis.sqlite.connect() + t = con.create_table('test_series_ibis', schema=ibis.schema({'a': 'int64'})) + s = Series(t['a']) + + # Execute + expr = s.to_ibis() + + # Assert + assert isinstance(expr, ibis_types.Column) + assert expr.equals(t['a']) From b2dcd452c92eec4ba6a1d43a8403205c2de41bd8 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 12 Dec 2025 23:04:50 +0000 Subject: [PATCH 2/2] Add to_ibis() method to DataFrame and Series This commit adds a `to_ibis()` method to both `DataFrame` and `Series` classes. This method allows users to access the underlying Ibis expression (`_data`) for more advanced operations or interoperability with Ibis directly. Tests were added in `tests/test_to_ibis.py` to verify the functionality. --- tests/test_to_ibis.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/test_to_ibis.py b/tests/test_to_ibis.py index 5f3b0b7..8e9bfe9 100644 --- a/tests/test_to_ibis.py +++ b/tests/test_to_ibis.py @@ -1,7 +1,4 @@ -import pytest -import pandas as pd -import leanframe as lf import ibis import ibis.expr.types as ibis_types from leanframe.core.frame import DataFrame