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.
我使用 loc 函数访问 pandas 中的行,如下所示:
pdf.loc[pdf.a>2]
这是矢量化的吗?它比使用 numpy 更好吗
pdf[pdf.a>2]
这个时间表明 loc 没有减速
testa = pd.DataFrame(np.arange(10000000),columns =['q']) %timeit testb = testa.loc[testa.q>6] %timeit testc = testa[testa.q>7]
1 loop, best of 3: 207 ms per loop 1 loop, best of 3: 208 ms per loop