I'm trying to convert an R matrix to a pandas dataframe. I am using:
import pandas.rpy.common as com
df = com.convert_to_r_dataframe(r_matrix)
And I get:
TypeError: 'float' object cannot be interpreted as an index
Strangely enough this use case is omitted from all documentation I have come across. I would also settle for a conversion of the R matrix to a numpy
array
- since I will want to iterate over the rows anyway.
I think you are getting confused about the difference between
convert_to_r_dataframe
andconvert_robj
. Use the former one for converting TOR
, and the latter one for converting BACK fromR
:Just use
numpy.array()
: