Numpy 和 Pandas 之间有性能差异吗? [英] Is there a performance difference between Numpy and Pandas?
问题描述
假设我将使用 Numpy 数组,我已经编写了大量代码.原来我得到的数据是通过 Pandas 加载的.我现在记得我在 Pandas 中加载它,因为我在 Numpy 中加载它时遇到了一些问题.我认为数据太大了.
I've written a bunch of code on the assumption that I was going to use Numpy arrays. Turns out the data I am getting is loaded through Pandas. I remember now that I loaded it in Pandas because I was having some problems loading it in Numpy. I believe the data was just too large.
所以我想知道,在使用 Numpy 和 Pandas 时,计算能力有区别吗?
Therefore I was wondering, is there a difference in computational ability when using Numpy vs Pandas?
如果 Pandas 更高效,那么我宁愿为 Pandas 重写我的所有代码,但如果没有更高的效率,那么我将只使用一个 numpy 数组...
If Pandas is more efficient then I would rather rewrite all my code for Pandas but if there is no more efficiency then I'll just use a numpy array...
推荐答案
可能存在显着的性能差异,乘法的数量级和索引一些随机值的数量级.
There can be a significant performance difference, of an order of magnitude for multiplications and multiple orders of magnitude for indexing a few random values.
我其实也在想同样的事情,并发现了这个有趣的比较:http://penandpants.com/2014/09/05/performance-of-pandas-series-vs-numpy-arrays/
I was actually wondering about the same thing and came across this interesting comparison: http://penandpants.com/2014/09/05/performance-of-pandas-series-vs-numpy-arrays/
这篇关于Numpy 和 Pandas 之间有性能差异吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!