Conversion from rpy2's R DataFrame to pandas DataFrame

Issue #123 resolved
Laurent Gautier created an issue

The conversion pandas -> rpy2 is implemented, but rpy2 -> pandas is not.

In that direction, copying should probably be avoided whenever possible by using numpy's as.array whenever possible. See the relevant rpy2 documentation.

Comments (7)

  1. Dav Clark

    OK - I've had a look around the code, and have made a few modest updates, which you can see at davclark/rpy2@35d4ed2 (my pandas-tests branch, note the link is in "GitHub flavored Markdown" which doesn't work here, but hopefully it's clear enough to read even if the link is broken). The main update is a test that fails because ri2pandas raises an error. There was a missing raise for the ri2pandas error, so I changed that code also.

    There's also a cleanup commit there that isn't properly about pandas testing, but figured it was worth fixing and not worth making another branch.

    In any case, I figured I'd start with submitting a small patch like this to figure out the workflow. At this point, it'd be trivial to re-do the patch in a different way if that's what you'd prefer. I tried making a pull request, but I don't have permission for that.

  2. Laurent Gautier reporter

    GitHub UI is quite ahead of bitbucket's nowadays. Link here.

    I am surprised that you can't make a pull request (all pull requests I received were from people who forked without me involved).

  3. Dav Clark

    One more thing... the way things are set up in ipython is very brittle right now, because of the way they are directly grabbing the converter functions. The ideal architecture would make that more robust, and allow the user to change the conversion process at runtime (as with pandas2ri.activate).

  4. Log in to comment