Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个相当大的数据集raw,我最初选择这样的行:
raw
raw = np.array(Some Matrix) selected = [r for r in raw if r[1] == '20130525' and r[2] < 120000]
但这真的很慢,有人知道如何使用 Numpy 的内置函数加快速度吗?
这将是标准的 numpythonic 方法:
selected = raw[(raw[:, 1] == '20130525') & (raw[:, 2] == 120000)]
object但是,正如混合数据类型所暗示的那样,如果您有一个类型数组,那么加速可能会很微不足道。你到底在处理什么?你可以改用recarray吗?
object