From efb091ef126f0c4e06560c7f2a3fea061f567f96 Mon Sep 17 00:00:00 2001 From: jreback Date: Fri, 6 Dec 2013 13:28:23 -0500 Subject: [PATCH] PERF: performance regression in frame/apply (GH5654) --- pandas/core/frame.py | 2 +- vb_suite/frame_methods.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 5e31b14fa7bd3..d0a1511ec1cca 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -3434,7 +3434,7 @@ def _apply_standard(self, func, axis, ignore_failures=False, reduce=True): if self._is_mixed_type: # maybe a hack for now raise AssertionError('Must be mixed type DataFrame') - values = self.values.ravel() + values = self.values dummy = Series(NA, index=self._get_axis(axis), dtype=values.dtype) diff --git a/vb_suite/frame_methods.py b/vb_suite/frame_methods.py index 63b2a154c75e9..ee4d876d20233 100644 --- a/vb_suite/frame_methods.py +++ b/vb_suite/frame_methods.py @@ -289,3 +289,12 @@ def f(K=100): frame_isnull = Benchmark('isnull(df)', setup, start_date=datetime(2012,1,1)) +#---------------------------------------------------------------------- +# apply + +setup = common_setup + """ +s = Series(np.arange(1028.)) +df = DataFrame({ i:s for i in range(1028) }) +""" +frame_apply_user_func = Benchmark('df.apply(lambda x: np.corrcoef(x,s)[0,1])', setup, + start_date=datetime(2012,1,1))