Closed
Description
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?).