RMagic,IPython和摘要信息 [英] RMagic, IPython and Summary Information

查看:116
本文介绍了RMagic,IPython和摘要信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照此处的示例

http://www.randalolson.com/2013/01/14/filling-in-pythons-gaps-in-statistics-packages-with- rmagic /

我在IPython笔记本中的不同数据集上尝试了相同的操作。

I tried the same on a different data set found here, in an IPython notebook.

https://github.com/burakbayramli/kod/blob/ master / delltest / dell.tgz

from pandas import *
orders = read_csv("dell.csv",sep=",")
%load_ext rmagic
%R -i orders print(summary(orders))

我得到

     Length Class  Mode
[1,] 25     -none- list
[2,] 25     -none- list
[3,] 25     -none- list
..

然而R

data <- read.csv ("dell.csv",header=TRUE,sep=",")
print (summary(data))

给我正确的摘要信息。

gives me the correct summary information.

      rank        per_customer_count total_total_amount    orderid     
 Min.   : 1.000   Min.   : 1.000     Min.   :    0.14   Min.   :    1  
 1st Qu.: 2.000   1st Qu.: 6.000     1st Qu.:  866.11   1st Qu.: 2964  
 Median : 4.000   Median : 8.000     Median : 1764.08   Median : 5980  
 Mean   : 4.997   Mean   : 9.426     Mean   : 2004.95   Mean   : 5987  
 3rd Qu.: 7.000   3rd Qu.:12.000     3rd Qu.: 2856.06   3rd Qu.: 9004  
 ...

任何想法?

推荐答案

我快速看了一下,似乎有很多情况下ipython magic
不是获得正确的转换。我必须与他们取得联系,关于rmagic和
更多的魔力。

I had a quick look and there appear to be a number of situations in which the ipython magic is not getting the conversion right. I have to get in touch with them regarding rmagic and more magic.

在此期间,你应该能够做出你需要进步的东西下面的代码片段:

In the meantime, you should be able to cook up what you need to progress from the snippet of code below:

import pandas
orders = pandas.read_csv("dell.csv", sep=",")
%load_ext rmagic

import rpy2.robjects
d = dict()
for i, (k,v) in enumerate(orders.iteritems()):
    print("%s (type: %s - %i/%i)" %(k, v.dtype.kind, i, orders.shape[1]))
    if v.dtype.kind == 'O':
      v = rpy2.robjects.vectors.StrVector(v)
    d[k] = rpy2.robjects.conversion.py2ri(v)
df = rpy2.robjects.DataFrame(d)

def print_rsummary(x):
    print(rpy2.robjects.baseenv['summary'](x))

print_rsummary(df)

这篇关于RMagic,IPython和摘要信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆