【发布时间】:2013-09-03 14:49:55
【问题描述】:
我想将 pandas 与 R 结合使用,所以我做到了:
import pandas as pd
import rpy2.robjects as robjects
>>> df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]},index=["one", "two"])
>>> robjects.r.cor(df.A, df.B)
ValueError: Nothing can be done for the type <class 'pandas.core.series.Series'> at the moment.
这是否意味着我还不能在 rpy2 中使用 pandas 的对象?
然后我尝试了:
import pandas.rpy.common as com
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]},index=["one", "two"])
rdf = com.convert_to_r_dataframe(df)
但是我将如何使用rdf 完成上述操作?例如,rdf['A'] 给了我一个TypeError
【问题讨论】: