File tree 3 files changed +19
-6
lines changed
3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,6 @@ pandas 0.5.1
59
59
micro-performance tweaks (GH #360)
60
60
- Add `cov` instance methods to Series and DataFrame (GH #194, PR #362)
61
61
62
-
63
62
**Improvements to existing features **
64
63
65
64
- Sped up `DataFrame.apply ` performance in most cases
@@ -84,6 +83,10 @@ pandas 0.5.1
84
83
motivated by PR #355
85
84
- Cythonized `cache_readonly `, resulting in substantial micro-performance
86
85
enhancements throughout the codebase (GH #361)
86
+ - Special Cython matrix iterator for applying arbitrary reduction operations
87
+ with 3-5x better performance than `np.apply_along_axis ` (GH #309)
88
+ - Add `raw ` option to `DataFrame.apply ` for getting better performance when
89
+ the passed function only requires an ndarray (GH #309)
87
90
88
91
**Bug fixes **
89
92
Original file line number Diff line number Diff line change @@ -54,18 +54,21 @@ cdef class Reducer:
54
54
arr = self .arr
55
55
chunk = self .dummy
56
56
57
- result = np.empty(self .nresults, dtype = self .arr.dtype)
58
- it = < flatiter> PyArray_IterNew(result)
59
-
60
- test = self .f(self .chunk)
57
+ test = self .f(chunk)
61
58
try :
59
+ assert (not isinstance (test, np.ndarray))
60
+ if hasattr (test, ' dtype' ):
61
+ result = np.empty(self .nresults, dtype = test.dtype)
62
+ else :
63
+ result = np.empty(self .nresults, dtype = ' O' )
62
64
result[0 ] = test
63
65
except Exception :
64
66
raise ValueError (' function does not reduce' )
65
67
68
+ it = < flatiter> PyArray_IterNew(result)
69
+
66
70
dummy_buf = chunk.data
67
71
chunk.data = arr.data
68
-
69
72
try :
70
73
for i in range (self .nresults):
71
74
PyArray_SETITEM(result, PyArray_ITER_DATA(it),
@@ -76,6 +79,9 @@ cdef class Reducer:
76
79
# so we don't free the wrong memory
77
80
chunk.data = dummy_buf
78
81
82
+ if result.dtype == np.object_:
83
+ result = maybe_convert_objects(result)
84
+
79
85
return result
80
86
81
87
def reduce (arr , f , axis = 0 , dummy = None ):
Original file line number Diff line number Diff line change @@ -10,3 +10,7 @@ cdef class SeriesIterator:
10
10
11
11
def next (self ):
12
12
pass
13
+
14
+ def foo (object o ):
15
+ cdef int64_t bar = o
16
+ return bar
You can’t perform that action at this time.
0 commit comments