Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions great_tables/_tbl_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
PlSelectExpr = _selector_proxy_
PlExpr = pl.Expr

PdSeries = pd.Series
PdSeries = pd.Series[Any]
PlSeries = pl.Series
PyArrowArray = pa.Array
PyArrowChunkedArray = pa.ChunkedArray
PyArrowArray = pa.Array[Any]
PyArrowChunkedArray = pa.ChunkedArray[Any]
Comment on lines -32 to +35
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason for this is that I was getting warnings that

SeriesLike is partially unknown


PdNA = pd.NA
PlNull = pl.Null
Expand Down Expand Up @@ -763,7 +763,7 @@ def _(df: PyArrowTable, x: Any) -> bool:
import pyarrow as pa

arr = pa.array([x])
return arr.is_null().to_pylist()[0] or arr.is_nan().to_pylist()[0]
return arr.is_null(nan_is_null=True).to_pylist()[0]
Copy link
Contributor Author

@FBruzzesi FBruzzesi Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason for this change is that .is_nan raises an exception for non-numeric arrays. It was not tested for pyarrow before



@singledispatch
Expand Down
71 changes: 71 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from __future__ import annotations

from importlib.util import find_spec

import pytest

from great_tables._tbl_data import DataFrameLike, _re_version
from tests.utils import DataFrameConstructor, DataLike


def pandas_constructor(obj: DataLike) -> DataFrameLike:
import pandas as pd

return pd.DataFrame(obj) # type: ignore[no-any-return]


def pandas_nullable_constructor(obj: DataLike) -> DataFrameLike:
import pandas as pd

return pd.DataFrame(obj).convert_dtypes(dtype_backend="numpy_nullable") # type: ignore[no-any-return]


def pandas_pyarrow_constructor(obj: DataLike) -> DataFrameLike:
import pandas as pd

return pd.DataFrame(obj).convert_dtypes(dtype_backend="pyarrow") # type: ignore[no-any-return]


def polars_constructor(obj: DataLike) -> DataFrameLike:
import polars as pl

return pl.DataFrame(obj)


def pyarrow_table_constructor(obj: DataLike) -> DataFrameLike:
import pyarrow as pa

return pa.table(obj) # type: ignore[no-any-return]


frame_constructors: list[DataFrameConstructor] = []

is_pandas_installed = find_spec("pandas") is not None
is_polars_installed = find_spec("polars") is not None
is_pyarrow_installed = find_spec("pyarrow") is not None

if is_pandas_installed:
import pandas as pd

frame_constructors.append(pandas_constructor)

pandas_ge_v2 = _re_version(pd.__version__) >= (2, 0, 0)

if pandas_ge_v2:
frame_constructors.append(pandas_nullable_constructor)

if pandas_ge_v2 and is_pyarrow_installed:
# pandas 2.0+ supports pyarrow dtype backend
# https://pandas.pydata.org/docs/whatsnew/v2.0.0.html#new-dtype-backends
frame_constructors.append(pandas_pyarrow_constructor)

if is_polars_installed:
frame_constructors.append(polars_constructor)

if is_pyarrow_installed:
frame_constructors.append(pyarrow_table_constructor)


@pytest.fixture(params=frame_constructors)
def frame_constructor(request: pytest.FixtureRequest) -> DataFrameConstructor:
return request.param # type: ignore[no-any-return]
Loading
Loading