0

I have one function in R. I want to use that function in python.But I am getting error while passing arguments.

Calling R function from python referenced from calling a R function from python code with passing arguments this site.

I have tried like below with my exisiting function

path=""
actual_values= data['col1']
predicted_values = data['col2']
def function1(input1,output):
    r=ro.r
    r.source(path+"script.R")
    p=r.metrics_fun(input1,output) # function name in the R is metrics_fun
    return p
output_df = function1(actual_values,predicted_values)

I am getting error like below

NotImplementedError: Conversion 'py2rpy' not defined for objects of type '<class 'pandas.core.series.Series'>'

Please, help me to find solution for this.

3
  • Does this answer your question? Python Pandas to R dataframe Commented Feb 24, 2021 at 9:00
  • It is not about converting python dataframe to R data frame. I want to use the function which is defined in R script.While I am passing pandas dataframe columns it is giving the error while using above method. Error:module 'base' has no attribute 'fun_name' . Commented Feb 24, 2021 at 10:01
  • It is easier to help when the example is complete (self-contained). Here there is no indication about what type are the objects passed when calling R, or what Python modules are imported. Also, did you check the rpy2 documentation? For example, rpy2.github.io/doc/v3.4.x/html/pandas.html Commented Feb 28, 2021 at 15:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.