Skip to content

Commit 26d66c1

Browse files
committed
PERF: vbenches for DataFrame.apply
1 parent 98c8146 commit 26d66c1

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

vb_suite/frame_methods.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,43 @@ def f(K=100):
324324
df = DataFrame({ i:s for i in range(1028) })
325325
"""
326326
frame_apply_user_func = Benchmark('df.apply(lambda x: np.corrcoef(x,s)[0,1])', setup,
327+
name = 'frame_apply_user_func',
327328
start_date=datetime(2012,1,1))
328329

330+
setup = common_setup + """
331+
df = DataFrame(np.random.randn(1000,100))
332+
"""
333+
frame_apply_lambda_mean = Benchmark('df.apply(lambda x: x.sum())', setup,
334+
name = 'frame_apply_lambda_mean',
335+
start_date=datetime(2012,1,1))
336+
setup = common_setup + """
337+
df = DataFrame(np.random.randn(1000,100))
338+
"""
339+
frame_apply_np_mean = Benchmark('df.apply(np.mean)', setup,
340+
name = 'frame_apply_np_mean',
341+
start_date=datetime(2012,1,1))
342+
343+
setup = common_setup + """
344+
df = DataFrame(np.random.randn(1000,100))
345+
"""
346+
frame_apply_pass_thru = Benchmark('df.apply(lambda x: x)', setup,
347+
name = 'frame_apply_pass_thru',
348+
start_date=datetime(2012,1,1))
349+
350+
setup = common_setup + """
351+
df = DataFrame(np.random.randn(1000,100))
352+
"""
353+
frame_apply_axis_1 = Benchmark('df.apply(lambda x: x+1,axis=1)', setup,
354+
name = 'frame_apply_axis_1',
355+
start_date=datetime(2012,1,1))
356+
357+
setup = common_setup + """
358+
df = DataFrame(np.random.randn(1000,3),columns=list('ABC'))
359+
"""
360+
frame_apply_ref_by_name = Benchmark('df.apply(lambda x: x["A"] + x["B"],axis=1)', setup,
361+
name = 'frame_apply_ref_by_name',
362+
start_date=datetime(2012,1,1))
363+
329364
#----------------------------------------------------------------------
330365
# dtypes
331366

0 commit comments

Comments
 (0)