Skip to content

Instantly share code, notes, and snippets.

@adxrgh
Created April 30, 2017 14:29
Show Gist options
  • Save adxrgh/341a924cca1230d32865b0579e748679 to your computer and use it in GitHub Desktop.
Save adxrgh/341a924cca1230d32865b0579e748679 to your computer and use it in GitHub Desktop.
[for i,r in t.iterrows():]
t = pd.DataFrame({'a': range(0, 10000), 'b': range(10000, 20000)})
B = []
C = []
A = time.time()
for i,r in t.iterrows():
C.append((r['a'], r['b']))
B.append(time.time()-A)
C = []
A = time.time()
for ir in t.itertuples():
C.append((ir[1], ir[2]))
B.append(time.time()-A)
C = []
A = time.time()
for r in zip(t['a'], t['b']):
C.append((r[0], r[1]))
B.append(time.time()-A)
print B
Result:
[0.5639059543609619, 0.017839908599853516, 0.005645036697387695]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment