Skip to content

GH-51696: Remove stale float16 guard in from_dataframe - #53727

Closed
Asthenia0412 wants to merge 1 commit into
apache:mainfrom
Asthenia0412:GH-51696-remove-stale-float16-guard
Closed

Asthenia0412 wants to merge 1 commit into
apache:mainfrom
Asthenia0412:GH-51696-remove-stale-float16-guard

Conversation

@Asthenia0412

@Asthenia0412 Asthenia0412 commented Oct 14, 2026 •

Copy link
Copy Markdown

Background

A stale guard in from_dataframe.py rejects pandas float16 columns with NaN values, claiming pc.is_nan has no float16 kernel.

Problem

Every from_dataframe() call with a float16 DataFrame raises NotImplementedError.

Solution

Removed the outdated guard block. PR #46866 already added float16 support to pc.is_nan (GH-45083), so float16 now flows through the same code path as other float widths.

Testing

Verified that from_dataframe(pd.DataFrame({'h': np.array([1.5, np.nan], dtype='<f2')})) now succeeds and produces a table with correct null handling.

Also updated the existing test test_pandas_to_pyarrow_float16_with_missing to verify correct behavior instead of expecting NotImplementedError.

The guard rejecting float16 columns with NaN values was added because
pc.is_nan didn't have a float16 kernel at the time. PR apache#46866 (apacheGH-45083)
later added that kernel, making this guard obsolete.

Removing the guard allows pandas float16 DataFrames to be imported
via from_dataframe() properly.

Also update test_pandas_to_pyarrow_float16_with_missing to verify the
correct behavior instead of expecting NotImplementedError.

@rok rok left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

While this is a valid PR it might ultimately not be needed. See comments here: #51696

@@ -319,14 +319,13 @@ def test_pandas_to_pyarrow_with_missing(np_float_str):

@pytest.mark.pandas
def test_pandas_to_pyarrow_float16_with_missing():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perhaps it's better to just removetest_pandas_to_pyarrow_float16_with_missing test and make sure pc.is_nan on float16 is tested where all other types are tested.

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