I am using the reticulate package to integrate Python into an R package I'm building. One of the capabilities I need is to return R data.frames from a method in the R6 based object model I'm building. I utilize Python Pandas package to create a DataFrame in the reticulate python environment. My objective is to return this an R data.frame. The issue I'm seeing is that when I used reticulate::py_to_r(df) it does not convert to R and instead it returns a python DataFrame object. Below is a simple test I'm doing:
# platform x86_64-pc-linux-gnu
# arch x86_64
# os linux-gnu
# system x86_64, linux-gnu
# status
# major 3
# minor 4.4
# year 2018
# month 03
# day 15
# svn rev 74408
# language R
# version.string R version 3.4.4 (2018-03-15)
# nickname Someone to Lean On
library(reticulate)
pd <- import("pandas",as = "pd",convert = FALSE)
aa <- pd$read_csv("CDM_LOCATION.csv")
df <- reticulate::py_to_r(aa)
print(class(df))
df
[1] "pd.core.frame.DataFrame" "pd.core.generic.NDFrame" "pd.core.base.PandasObject"
[4] "pd.core.base.StringMixin" "pd.core.accessor.DirNamesMixin" "pd.core.base.SelectionMixin"
[7] "python.builtin.object"
Am I using the wrong method of transforming a DataFrame from Python to R? Feedback will be appreciated!
Thank you,
Brett