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

AsIs class in R dataframe conversion prevents easy plotting w/ ggplot2 #8255

Closed
benjschiller opened this issue Sep 12, 2014 · 1 comment
Closed
Labels
Dtype Conversions Unexpected or buggy dtype conversions

Comments

@benjschiller
Copy link
Contributor

When using pandas.rpy.common.convert_to_r_dataframe to convert pandas DataFrame --> R data.frame, columns get assigned two classes: AsIs, some data type

ggplot2 sees AsIs and refuses to deal with the data type properly. It would be nice to have the AsIs automatically stripped like here:
http://stackoverflow.com/questions/25175530/can-rpy2-code-be-run-in-parallel

I put the hack in my code like this:

from rpy2.robjects import r as R
hack_pandas = R("""
    function(df) {
        data.frame(lapply(df, function(X) {
            if ("AsIs" %in% class(X))
                class(X) <- class(X)[-match("AsIs", class(X))]
            X
        }))
    }
""")

df = hack_pandas(com.convert_to_r_dataframe(data))

It would be nice to have this done on-the-fly, perhaps optionally (strip_asis=True?).

@jreback jreback added the Dtype Conversions Unexpected or buggy dtype conversions label Mar 6, 2015
@jreback jreback mentioned this issue Mar 6, 2015
5 tasks
@jreback
Copy link
Contributor

jreback commented Mar 8, 2015

redirect to rpy2 for these types of conversions, see #9602

@jreback jreback closed this as completed Mar 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

No branches or pull requests

2 participants