相关疑难解决方法(0)

熊猫标量值获取和设置:ix还是iat?

我想弄清楚何时在pandas DataFrame中使用不同的选择方法.特别是,我正在寻找访问标量值.我经常听到ix一般的推荐.但在pandas文档中 ,建议使用atiat快速标量值访问:

Since indexing with [] must handle a lot of cases (single-label access, slicing, boolean indexing, etc.), it has a bit of overhead in order to figure out what you’re asking for. If you only want to access a scalar value, the fastest way is to use theand iat methods, which are implemented on all of the data structures.

因此,我认为iat应该更快地获取和设置单个单元格.然而,经过一些测试,我们发现ix读取细胞的速度相当或更快,而iat为细胞分配值要快得多.

这种行为记录在哪里吗?它总是如此,为什么会发生这种情况?是否必须对返回视图或复制执行某些操作?如果有人能对这个问题有所了解并解释建议获取和设置单元格值以及原因,我将不胜感激.

以下是使用pandas的一些测试(版本0.15.2).

为了确保此行为不是此版本的错误,我还在0.11.0上测试了它.我没有提供结果,但趋势完全相同 …

python indexing pandas

9
推荐指数
1
解决办法
3428
查看次数

标签 统计

indexing ×1

pandas ×1

python ×1