Visitar URL original
GH-51696: [Python] Support float16 columns with NaN null kind in from_dataframe by amanmaurya92 · Pull Request #51716 · apache/arrow · GitHub
Skip to content

GH-51696: [Python] Support float16 columns with NaN null kind in from_dataframe - #51716

Open
amanmaurya92 wants to merge 1 commit into
apache:mainfrom
amanmaurya92:gh-51696-interchange-float16
Open

amanmaurya92 wants to merge 1 commit into
apache:mainfrom
amanmaurya92:gh-51696-interchange-float16

Conversation

@amanmaurya92

Copy link
Copy Markdown

Rationale for this change

pa.interchange.from_dataframe previously raised NotImplementedError for float16 columns with ColumnNullType.USE_NAN because pyarrow.compute.is_nan lacked a half-float kernel.
Since GH-45083 added the is_nan half-float kernel, this guard is no longer necessary.

What changes are included in this PR?

  • Removed the stale float16 NotImplementedError guard in validity_buffer_nan_sentinel().
  • Updated test_pandas_to_pyarrow_float16_with_missing in python/pyarrow/tests/interchange/test_conversion.py to assert proper conversion to pa.float16() with nulls.

Are these changes tested?

Yes, tested via unit tests in python/pyarrow/tests/interchange/test_conversion.py.

Are there any user-facing changes?

Yes, from_dataframe now successfully converts DataFrames containing float16 columns with NaN nulls rather than raising NotImplementedError.

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #51696 has been automatically assigned in GitHub to PR creator.

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #51696 has no components, please add labels for components.

@chrikrah chrikrah left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@amanmaurya92 measured at 334f08d: a pandas float16 column with NaN now imports as halffloat with a null, as reported in #51696, and the updated test fails on the old guard.

$ python -c 'import numpy as np, pandas as pd; from pyarrow.interchange import from_dataframe
print(from_dataframe(pd.DataFrame({"h": np.array([1.5, np.nan], dtype="<f2")}))["h"])'
# base e85e181: NotImplementedError: (<DtypeKind.FLOAT: 2>, 16, 'e', '=') with 1 is not yet supported.
# head 334f08d: [[1.5, null]]

$ python -m pytest -q pyarrow/tests/interchange/     # pyarrow 26.0.0 wheel, pandas 3.1.0rc0, CPython 3.12
# base e85e181: 3045 passed, 2 skipped
# head 334f08d: 3045 passed, 2 skipped
# head test, from_dataframe.py from e85e181: 1 failed, 3044 passed, 2 skipped
FAILED tests/interchange/test_conversion.py::test_pandas_to_pyarrow_float16_with_missing
# from_dataframe.py on main 5ef3c52 is unchanged since e85e181

Whether this lands, given the planned deprecation in #49629, is the maintainers' call and is already asked on #51696. If they want it kept, I can re-run the same check on a rebase onto main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants