[Numpy-tickets] [NumPy] #558: 'axis' support for numpy.median()
NumPy
numpy-tickets@scipy....
Tue Jul 31 08:27:27 CDT 2007
#558: 'axis' support for numpy.median()
-------------------------+--------------------------------------------------
Reporter: cdavid | Owner: somebody
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: Other | Version: none
Severity: normal | Resolution:
Keywords: |
-------------------------+--------------------------------------------------
Comment (by joris):
Proposed code:
def median(a, axis=0):
sorted = array(a, subok=True, copy=True).swapaxes(0,axis)
sorted.sort(axis=0)
index = int(sorted.shape[0]/2)
if sorted.shape[0] % 2 == 1:
return sorted[index]
else:
return (sorted[index-1]+sorted[index])/2.0
--
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/558#comment:2>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list