- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我认为简单的问题但尚未找到答案。如何摆脱数据框中的“AsIs”类属性。它阻止 foreign
包中的 write.dbf
转换为 dbf。我正在使用 rpy2,但它确实适用于没有“AsIs”的 R 数据帧。我把完整的代码放在错误消息下面。 dbfs = write_dbf(r_dataframe)
Error in function (dataframe, file, factor2char = TRUE, max_nchar = 254) :
data frame contains columns of unsupported class(es) AsIs
---------------------------------------------------------------------------
RRuntimeError Traceback (most recent call last)
<ipython-input-26-9072df63231a> in <module>()
----> 1 dbfs = write_dbf(r_dataframe)
/home/matthew/.virtualenvs/mypython/lib/python3.2/site-packages/rpy2-2.2.6dev_20120814-py3.2-linux-i686.egg/rpy2/robjects/functions.py in __call__(self, *args, **kwargs)
80 v = kwargs.pop(k)
81 kwargs[r_k] = v
---> 82 return super(SignatureTranslatedFunction, self).__call__(*args, **kwargs)
/home/matthew/.virtualenvs/mypython/lib/python3.2/site-packages/rpy2-2.2.6dev_20120814-py3.2-linux-i686.egg/rpy2/robjects/functions.py in __call__(self, *args, **kwargs)
32 for k, v in kwargs.items():
33 new_kwargs[k] = conversion.py2ri(v)
---> 34 res = super(Function, self).__call__(*new_args, **new_kwargs)
35 res = conversion.ri2py(res)
36 return res
RRuntimeError: Error in function (dataframe, file, factor2char = TRUE, max_nchar = 254) :
data frame contains columns of unsupported class(es) AsIs
我正在使用 python rpy2 与 R 对话。这不是问题所在,但这是我的代码。如果我使用 R 中没有“AsIs”的数据帧,则 write.dbf 可以从 Rpy2 运行。
( python )
df = DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C':[7,8,9]},index=["one", "two", "three"]) I am going from python pandas dataframe to and R datafram using
fore = importr("foreign")
In [19]:
r_dataframe = com.convert_to_r_dataframe(df)
In [20]:
print(type(r_dataframe))
<class 'rpy2.robjects.vectors.DataFrame'>
In [32]:
r_dataframe
Out[32]:
<DataFrame - Python:0xb3db8ac / R:0xc23ac50>
[IntVector, IntVector, IntVector]
A: <class 'rpy2.robjects.vectors.IntVector'>
<IntVector - Python:0xc1fb1ec / R:0xc23ac28>
[ 1, 2, 3]
B: <class 'rpy2.robjects.vectors.IntVector'>
<IntVector - Python:0xc1fb36c / R:0xc23ac00>
[ 4, 5, 6]
C: <class 'rpy2.robjects.vectors.IntVector'>
<IntVector - Python:0xc1fb4ec / R:0xc23abd8>
[ 7, 8, 9]
print(r_dataframe)
A B C
one 1 4 7
two 2 5 8
three 3 6 9
In [25]:
write_dbf =robjects.r("write.dbf")
read_dbf = robjects.r("read.dbf")
In [26]:
dbfs = write_dbf(r_dataframe)
Error in function (dataframe, file, factor2char = TRUE, max_nchar = 254) :
data frame contains columns of unsupported class(es) AsI
dbfs = write_dbf(r_dataframe)
最佳答案
以下是我如何删除 AsIs
类属性。请注意,我注意保留向量可能具有的任何其他类属性:
unAsIs <- function(X) {
if("AsIs" %in% class(X)) {
class(X) <- class(X)[-match("AsIs", class(X))]
}
X
}
## Show why the function is needed
a <- 1:10
b <- factor(1:10)
class(I(a))
# [1] "AsIs"
class(I(b))
# [1] "AsIs" "factor"
## Show that the function reverses the effect of `I()`
identical(a, unAsIs(I(a)))
# [1] TRUE
identical(b, unAsIs(I(b)))
# [1] TRUE
关于r - 摆脱 "AsIs"类属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12865218/
这个问题已经有答案了: 已关闭11 年前。 Possible Duplicate: What are the rules for Javascript's automatic semicolon in
我正在使用 JSHint 对 JavaScript 进行 linting,并启用此选项 "asi": true, "white": true 避免在我的代码中使用分号。 但是我必须用括号开始我的新行,
我在我的 iPhone 应用程序中使用 ASIHTTPRequest 框架来管理 HTTP 通信。我按照他们在项目主页中给出的示例发送异步请求。在那里我们必须实现两个回调,一个用于 requestFi
我认为简单的问题但尚未找到答案。如何摆脱数据框中的“AsIs”类属性。它阻止 foreign 包中的 write.dbf 转换为 dbf。我正在使用 rpy2,但它确实适用于没有“AsIs”的 R 数
我制作了一个脚本,可以预加载 Sprite 表以在 this 中使用。带有 CSS Sprite ,但不会显示在 dsi 上。 这里是my current revision . 请告诉我哪里出错了。或
People often talk关于 JavaScript 令人讨厌的 ASI(自动分号插入),并经常引用 this example ... function a() { return [
好吧,首先我应该问一下这是否取决于浏览器。 我读到如果发现无效标记,但代码部分在该无效标记之前有效,如果标记前面有换行符,则会在标记前插入一个分号。 然而,对于由分号插入引起的错误引用的常见示例是:
在我的应用程序中,我发送了一个 ASI HTTP 发布请求,这样我的用户就可以向我的网络服务发布评论,但是我在发送请求时遇到了一些问题,它似乎总是失败我确信这是一个简单的错误我过目不忘,但它驱使着我。
这会触发 ASI(自动分号插入)吗? if (abc === def) { doSomething(); } // <-- here else { doDifferently();
好吧,首先我应该问这是否依赖于浏览器。 我读到,如果发现无效 token ,但该代码段在该无效 token 之前一直有效,则在 token 前面插入分号(如果 token 前面有换行符)。 但是,由分
好吧,首先我应该问这是否依赖于浏览器。 我读到,如果发现无效 token ,但该代码段在该无效 token 之前一直有效,则在 token 前面插入分号(如果 token 前面有换行符)。 但是,由分
由于我现在工作的地方发生了一场“宗教 war ”,我决定研究一下 javascript 的 ASI 特性的历史。 但我无法找出为什么以及何时将 ASI 引入 javascript。 它似乎一直是一个特
嗯,首先我应该问一下这是否取决于浏览器。 我已经读过,如果找到了一个无效的标记,但代码部分在该无效标记之前是有效的,如果它前面有一个换行符,则在该标记之前插入一个分号。 但是,由分号插入引起的错误引用
我需要使用 results = "asis" 原因如下:https://stackoverflow.com/a/36381976/ 但是,使用该 block 选项意味着其他输出呈现不理想。具体来说,我
我有一个输出可正确渲染的 html 代码的函数,但将其封装在带有“results = “asis””的 markdown 文档 R 代码块中失败。我将问题追溯到 HTML 代码中的空格。我喜欢这些空格
我正在编写一些辅助函数来将我的 R 变量转换为 JSON。我遇到过这个问题:我希望我的值被表示为 JSON 数组,这可以根据 RJSONIO 文档使用 AsIs 类来完成。 x = "HELLO" t
为了在查询中动态选择表名,我使用 psycopg2.extensions ( http://initd.org/psycopg/docs/extensions.html#psycopg2.extens
我一直在努力寻找一个好的解决方案,使用 ASI HTTP 库对 OAuth 2.0 用户进行身份验证。我来得有点短。有谁知道将此添加到 ASI HTTP 的库吗?我发现一个只适用于 OAuth 1.0
我需要显示表格列表(atm 表格是 ul 列表),如果包装器中没有足够的空间 - 应该会出现 asys X 上的滚动条。我知道这是纯 css,但我无法找出为什么元素不适合时会移到底部...... 我现
我正在创建一个非常简单的服务器,它接受来自浏览器 (Safari) 的 http 请求并响应一些转储 HTTP 响应,例如“Hello World”消息。 我的程序在 recv() 函数上被阻塞,因为
我是一名优秀的程序员,十分优秀!