我使用loc函数访问熊猫行:
<recipe-selects inline-template>
<div>
<table class='table table-striped'>
<thead>
</thead>
<tbody>
<tr v-for="(item, index) in recipes" :key="index">
<td class=""><a v-bind:href="'/recipe/'+item.id+'/view'" v-text="item.title"></a></td>
<td>
@{{item.overall_star}}
<review-stars :num-stars="item.overall_star" :recipe-name="item.title" >
</review-stars>
</td>
</tr>
</tbody>
</table>
</div>
</recipe-selects>
这是矢量化的吗?比使用numpy
好吗pdf.loc[pdf.a>2]
答案 0 :(得分:1)
这个时间表明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