jorisvandenbossche commented on issue #35535:
URL: https://github.com/apache/arrow/issues/35535#issuecomment-1543482341

   > So, if one were to interchange a `pandas.DataFrame` containing NaNs to a 
`pyarrow.Table`, one gets nulls in place of NaNs.
   
   AFAIK this is expected, because pandas creates an interchange object 
explicitly indicating that the NaN is used as the null value:
   
   ```
   In [15]: df.__dataframe__().get_column_by_name("foo").describe_null
   Out[15]: (<ColumnNullType.USE_NAN: 1>, None)
   ```
   
   And thus pyarrow correctly converts this to null on the Arrow side. 
   
   
   
   > I see interchanging another `pa.Table` with NaNs works fine, asummedly 
because `from_dataframe()` short-circuits when it gets a 
`pa.Table`/`pa.RecordBatch`.
   
   We are indeed short-cutting here. But even when not doing that (by 
explicitly using the lower level function that doesn't have this 
short-circuit), we preserve NaNs:
   
   ```
   In [22]: from pyarrow.interchange.from_dataframe import _from_dataframe
   
   In [23]: _from_dataframe(table.__dataframe__())
   Out[23]: 
   pyarrow.Table
   foo: double
   ----
   foo: [[nan]]
   ```
   
   That's because pyarrow does _not_ set that the NaN is the missing value 
indicator, and thus NaNs in the input are preserved.
   
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to