I am trying to load a pickle object in R, using the following process found online.
First, I create a Python file called: "pickle_reader.py":
import pandas as pd
def read_pickle_file(file):
pickle_data = pd.read_pickle(file)
return pickle_data
Then, I run the following R code:
install.packages('reticulate')
require("reticulate")
source_python("pickle_reader.py")
pickle_data <- read_pickle_file("pathname")
but I get an error that says:
Error in py_run_file_impl(file, local, convert) : ImportError: No module named pandas
N.B. I tried installing pandas again but this doesn't change the issue.
Do you know how should I proceed?
I find this to be a much more straight forward method than making a new .py
file. In an R code chunk do:
library(reticulate)
pd <- import("pandas")
x <- pd$read_pickle("file.pickle")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With