[Numpy-tickets] [NumPy] #558: 'axis' support for numpy.median()
NumPy
numpy-tickets@scipy....
Tue Jul 31 09:57:08 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):
Previously posted code should have been:
def median(a, axis=0):
sorted = array(a, subok=True, copy=True)
sorted = rollaxis(sorted, 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
This version has been checked against the SciPy version.
--
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/558#comment:3>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list