You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "lord (via GitHub)" <gi...@apache.org> on 2024/05/24 14:53:49 UTC

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

lord opened a new issue, #41812:
URL: https://github.com/apache/arrow/issues/41812

   ### Describe the bug, including details regarding any error messages, version, and platform.
   
   This small examples fails with `ValueError: Field pyarrow.Field<a: double not null> 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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Table.from_arrow can't import nan values into a non-null float column [arrow]

Posted by "tlm365 (via GitHub)" <gi...@apache.org>.
tlm365 commented on issue #41812:
URL: https://github.com/apache/arrow/issues/41812#issuecomment-2131154054

   @lord You just need to change the parameter `nullable` to `True`, then it will work.
   ```python
   schema = pa.schema([pa.field('a', pa.float64(), nullable=True)])
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org