Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Accept pd.NA as missing value in array constructor #25486

Closed
asfimport opened this issue Jul 10, 2020 · 2 comments
Closed

[Python] Accept pd.NA as missing value in array constructor #25486

asfimport opened this issue Jul 10, 2020 · 2 comments

Comments

@asfimport
Copy link
Collaborator

asfimport commented Jul 10, 2020

Currently we don't support using pandas.NA at all:

In [1]: import pyarrow as pa

In [2]: import pandas as pd

In [3]: pa.array([pd.NA, "A"])
---------------------------------------------------------------------------
ArrowInvalid                              Traceback (most recent call last)
<ipython-input-3-77e774fa8521> in <module>
----> 1 pa.array([pd.NA, "A"])

~/miniconda3/envs/fletcher/lib/python3.8/site-packages/pyarrow/array.pxi in pyarrow.lib.array()

~/miniconda3/envs/fletcher/lib/python3.8/site-packages/pyarrow/array.pxi in pyarrow.lib._sequence_to_array()

~/miniconda3/envs/fletcher/lib/python3.8/site-packages/pyarrow/error.pxi in pyarrow.lib.check_status()

ArrowInvalid: Could not convert <NA> with type NAType: did not recognize Python value type when inferring an Arrow data type

Reporter: Uwe Korn / @xhochy
Assignee: Wes McKinney / @wesm

Related issues:

PRs and other links:

Note: This issue was originally created as ARROW-9407. Please see the migration documentation for further details.

@asfimport
Copy link
Collaborator Author

Joris Van den Bossche / @jorisvandenbossche:
@wesm recently added support for pd.NA (ARROW-842, #7537), but apparently not yet for all cases.

First, from_pandas=True needs to be specified:

In [22]: pa.array(["A", pd.NA], from_pandas=True)                                                                                                                                                                  
Out[22]: 
<pyarrow.lib.StringArray object at 0x7ff2cf60fc48>
[
  "A",
  null
]

and thus doing like the above with a first typed element works. With pd.NA first it still doesn't work, so maybe that it is not yet correctly recognized as null where there is not yet an inferred type.

@asfimport
Copy link
Collaborator Author

Wes McKinney / @wesm:
Issue resolved by pull request 7714
#7714

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

No branches or pull requests

2 participants