Is there a way to store a pandas data frame in R format?
R has its own format that is significantly more expressive than csv (knows about factors, for example). The extension is usually .Rdata, and it is manipulated from R using the load
and save
functions.
I was wondering if the python pandas library know about this format? If not, is there another format (better than csv) for exchange between pandas and R?
I used to think for the longest time that you needed an R instance to deserialize R objects -- and loading a saved R object, or set of objects, amount to reading a (binary, likely compressed) data stream and de-serializing it.
But Davor proved me wrong. An existence proof is provided in his CPAN module Statistics-R-IO which does this in Perl. Presumably someone with enough motivation could abstract this into C library which many other projects, including Python, could load. Or use to save Pandas data for R.
Having a better data exchange would be nice. Otherwise, you can of course use language-agnostic interchange formats such as Protocol Buffers.
(Note: CPAN.org seems to be down/slow right now. Use Google Cache if need be.)
链接地址: http://www.djcxy.com/p/38404.html上一篇: Python熊猫到R数据框
下一篇: 有没有办法以R格式存储熊猫数据框?