Importing Rds Files In Python To Be Read As A Dataframe
I am very new in python. I have written my script in R and did a lot of analyses. But now I found that it should be converted to python. Anyway, I have problem with importing rds f
Solution 1:
This seems to be a bug when a certain version of rpy2 and pandas come together. Update them with, e.g.,
pip install --upgrade rpy2 pandas
and the error should disappear.
Solution 2:
Using the package pyreadr looks easier, install
pip install pyreadr
usage:
import pyreadr
result = pyreadr.read_r('test_data/basic/one.Rds')
# done! let's see what we got
print(result.keys()) # let's check what objects we got: there is only None
df1 = result[None] # extract the pandas data frame for the only object available
With the package you can write .rds files from python too.
Post a Comment for "Importing Rds Files In Python To Be Read As A Dataframe"