-
Notifications
You must be signed in to change notification settings - Fork 69
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
NA_character_ not identified as NaN after importing it into Python #983
Comments
Might be related: |
Thanks. This seems like a mistake in the conversion rules. The type of the column is In [8]: df.dtypes
Out[8]:
x object
dtype: object |
* The numpy converter did not list CHARSXP R objects as vectors. (issue #983) Also made the lookup for vector types a set (constant lookup time).
With the PR #989 merged one now gets: In [5]: df
Out[5]:
x
1 a
2 b
3 None
In [6]: df.isna()
Out[6]:
x
1 False
2 False
3 True |
Hello,
I would like to get a Python value (e.g. None) instead of NA_character_ |
I'm having this bug with RPY 3.5.16. I was able to get around it briefly by using an older version of rpy2 (due to #1106) and converting through 3.5.16 seems to be a severe regression in general when it comes to conversions. Previously I could run code like
|
I am using the following code inside a R magic cell:
However, when I run in another cell (a Python one):
I get
In fact, the imported dataframe is
The following fixes the problem:
df['x'] = df['x'].map(lambda val: np.nan if isinstance(val, rpy2.rinterface_lib.sexp.NACharacterType) else val)
My question is: Should not this be done automatically by
rpy2
?(For more details, please see: https://stackoverflow.com/questions/75223099/na-character-not-identidied-as-nan-after-importing-it-into-python-with-rpy2 )
The text was updated successfully, but these errors were encountered: