You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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?).
The text was updated successfully, but these errors were encountered:
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:
It would be nice to have this done on-the-fly, perhaps optionally (strip_asis=True?).
The text was updated successfully, but these errors were encountered: