def trimboth(a, proportiontocut, axis=<NUM_LIT:0>):
a = np.asarray(a)<EOL>if axis is None:<EOL><INDENT>a = a.ravel()<EOL>axis = <NUM_LIT:0><EOL><DEDENT>nobs = a.shape[axis]<EOL>lowercut = int(proportiontocut * nobs)<EOL>uppercut = nobs - lowercut<EOL>if (lowercut >= uppercut):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>sl = [slice(None)] * a.ndim<EOL>sl[axis] = slice(lowercut, uppercut)<EOL>return a[sl]<EOL>
Slices off a proportion of items from both ends of an array.

Slices off the passed proportion of items from both ends of the passed
array (i.e., with `proportiontocut` = 0.1, slices leftmost 10% **and**
rightmost 10% of scores).  You must pre-sort the array if you want
'proper' trimming.  Slices off less if proportion results in a
non-integer slice index (i.e., conservatively slices off
`proportiontocut`).

Parameters
----------
a : array_like
    Data to trim.
proportiontocut : float
    Proportion (in range 0-1) of total data set to trim of each end.
axis : int or None, optional
    Axis along which the observations are trimmed. The default is to trim
    along axis=0. If axis is None then the array will be flattened before
    trimming.

Returns
-------
out : ndarray
    Trimmed version of array `a`.

See Also
--------
trim_mean

Examples
--------
>>> from scipy import stats
>>> a = np.arange(20)
>>> b = stats.trimboth(a, 0.1)
>>> b.shape
(16,)