【发布时间】:2018-09-22 15:45:53
【问题描述】:
我有以下数据:
grp_m1 grp_m2 grp_m3 grp_m4
$50-$75 $50-$75 $50-$75 $50-$75
$50-$75 $50-$75 $50-$75 $50-$75
$150-$175 $150-$175 $150-$175 $150-$175
$100-$125 $100-$125 $100-$125 $100-$125
$150-$175 $125-$150 $125-$150 $125-$150
这些然后被转换为假人。这些假人的 dtype 在 pandas 数据帧中是 unsigned int ,当我尝试使用以下代码将其转换为 R 数据帧时:
from rpy2.robjects import pandas2ri
pandas2ri.activate()
pandas2ri.py2ri(data)
我收到以下错误:
Error while trying to convert the column "grp_m4_$175-$200". Fall back to string conversion. The error is: Cannot convert numpy array of unsigned values -- R does not have unsigned integers.
(name, str(e)))
C:\Users\hduser\AppData\Local\Continuum\anaconda3.1\lib\site-packages\rpy2-2.9.1-py3.6-win-amd64.egg\rpy2\robjects\pandas2ri.py:61: UserWarning: Error while trying to convert the column "grp_m4_$200-$225". Fall back to string conversion. The error is: Cannot convert numpy array of unsigned values -- R does not have unsigned integers.
(name, str(e)))
这可以修复还是我需要一起删除这些列,例如如果出现此错误,请跳过该列?
有人可以帮我解决这个问题吗?
【问题讨论】:
-
我不会说 python,但如果解决方案是将这些值转换为有符号整数,我不会感到惊讶。