apache / apache/arrow

[Python] Table.from_arrow can't import nan values into a non-null float column

Open
#41,812 0 comments 0 reactions 0 assignees View on GitHub
Component: Python Type: bug
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

### Describe the bug, including details regarding any error messages, version, and platform.

This small examples fails with `ValueError: Field pyarrow.Field was non-nullable but pandas column had 1 null values` on 16.1.0.

```
import pandas as pd
import pyarrow as pa

df = pd.DataFrame({"a": [1.0, float("nan")]})
schema = pa.schema([pa.field('a', pa.float64(), nullable=False)])
pa.Table.from_pandas(df, schema=schema)
```

I guess this seems like a bug to me, but I'm no pandas expert. It does feel like this makes roundtripping a non-null float column through pandas impossible?

### Component(s)

Python

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.