I need to read a csv file with python (into a pandas dataframe), work in R and return to python. Then, to pass pandas dataframe to R dataframe I use rpy2, and work ok (code bellow).
from pandas import read_csv, DataFrame
import pandas.rpy.common as com
import rpy2.robjects as robjects
r = robjects.r
r.library("fitdistrplus")
df = read_csv('./datos.csv')
r_df = com.convert_to_r_dataframe(df)
print(type(r_df))
And this output is:
<class 'rpy2.robjects.vectors.FloatVector'>
But then, I try to make a fit in R:
fit2 = r.fitdist(r_df, "weibull")
But I have this error:
RRuntimeError: Error in (function (data, distr, method = c("mle", "mme", "qme", "mge"), :
data must be a numeric vector of length greater than 1
I have 2nd question in this:
1_ What I do wrong?
2_ This is the most efficient way to pass a python dataframe to R? Because, I see this import: from rpy2.robjects.packages import importr
This is the data that I read: https://mega.co.nz/#!P8MEDSzQ!iQyxt73a5pRvJNOxWeSEaFlsVS7_A1sZCAXkUFBLJa0
I use Ipython 2.1 Thanks!