在 pandas 中加载.rds文件 [英] Loading a .rds file in Pandas
本文介绍了在 pandas 中加载.rds文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我下载了.rds格式的文件,如何用Pandas加载?它应该是R文件,但我找不到有关如何加载它的任何信息.
I have downloaded a file with format .rds, How can I load this with Pandas? It is supposed to be an R file but I haven't been able to find any info about how to load it.
推荐答案
您可以使用通过以下方式与熊猫的rpy2界面:
import rpy2.robjects as robjects
from rpy2.robjects import pandas2ri
pandas2ri.activate()
readRDS = robjects.r['readRDS']
df = readRDS('my_file.rds')
df = pandas2ri.ri2py(df)
# do something with the dataframe
这篇关于在 pandas 中加载.rds文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文