خرید بک لینک

Vote count: 0

I'm trying to understand the fastest way to loop through in pandas. I read in many places that itertuples is much better than just regularly looping through data, and the best is apply. If this is the case why do regular loops come out the fastest? Maybe I'm not understanding the results, what does 10 loops, best of 3 mean?

%%timeit
xlist= []
for row in toMood.itertuples():
    xlist.append(row[1] + 1)
1 loop, best of 3: 266 ms per loop
In [54]:


%%timeit
zlist = []
for row in toMood['user_id']:
    zlist.append(row + 1)
10 loops, best of 3: 83 ms per loop
In [56]:

%%timeit
tlist = toMood['user_id'].apply(lambda x: x+1)
10 loops, best of 3: 138 ms per loop

asked 11 secs ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 11 مرداد 1395 ساعت: 22:05

صفحه بندی