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

int64 type in python, got numeric type in R #729

Open
ssh352 opened this issue Mar 3, 2020 · 5 comments
Open

int64 type in python, got numeric type in R #729

ssh352 opened this issue Mar 3, 2020 · 5 comments

Comments

@ssh352
Copy link

ssh352 commented Mar 3, 2020

First thank the authors for such a useful package!

I have a python function. It returns a data frame, in python the column is int64. I use reticulate to call this function in R and save the data in a data.table. I check the column type and it is now numeric. In this process some digits of the column values are changed. Any idea how to avoid this problem?

@ssh352 ssh352 changed the title integer64 type in python, got numeric type in R int64 type in python, got numeric type in R Mar 3, 2020
@eddelbuettel
Copy link
Contributor

You can't as there is no (native) int64 in R, only a class wrapping a (64-bit) numeric giving int64 semantics.

@ssh352
Copy link
Author

ssh352 commented Mar 3, 2020

You can't as there is no (native) int64 in R, only a class wrapping a (64-bit) numeric giving int64 semantics.

Thank you Dirk, so perhaps I should convert the column from int64 to string in python first, pass it to R to avoid loss of precision, then use bit64 package as.integer64 to convert back to int64?

@eddelbuettel
Copy link
Contributor

There is no loss of precision of int64 when the bit64 package is used to represent it. But I forget the details -- you may need to turn it on, or maybe it happens, or ... Maybe check the unit tests or docs for reticulate to see how it is used?

@kevinushey
Copy link
Collaborator

There's a package adding (optional, opt-in) bit64 support that I intend to review soon:

#590

@colearendt
Copy link

Related to #323

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

No branches or pull requests

4 participants