The py_Numpy spreadsheet and associated code has been updated, with two new functions, links to the Numpy on-line help updated, and updates to sorting and polynomial functions. The updated code and spreadsheet can be downloaded from:
Updated Numpy files included in: py_SciPy.zip
Note that the Numpy code comes in 2 versions: pyNumpy-noJIT.py and pyNumpy-jit.py. The pyNumpy-jit.py requires the Numba just-in-time compiler to be installed, which provides very much faster results for maths intensive operations, compared with plain Python code. The default pyNumpy.py module is currently a copy of the noJIT version.
The py_SciPy download contains full open-source Python code and example spreadsheets for a wide range of Scipy functions, as well as the Numpy functions covered in this post. For more details, see the series of posts starting at: Scipy functions with Excel and pyxll. Also see Python and pyxll for details of the pyxll add-in, required to link my Python code to Excel.
This post will look at the two new functions, py_Where and py_Split, which can be found on the Array Functions tab of the py_Numpy spreadsheet. The other changes will be covered in the following post.
The py_Where function calls the Numpy “where”:
numpy.where(condition, [x, y, ]/)
Return elements chosen from x or y depending on condition.
The x, y return values are optional, and where omitted the function returns an array with the base 0 index values of the data values that satisfy the given condition, as shown in Column D below:

For this case the required inputs are:
- the data range (a single column or row)
- the condition, entered as text, one of <, <=, =, >=, or >
- the limit value
The output is a single column array with the base 0 index of the data values that satisfy the condition, in this case those that are <= 13.
Where x and y are specified typical output is shown in Column G above. Where the condition is satisfied x (‘Hearts’) is returned, and otherwise y (‘Spades’).
The py_Split function splits the data into a number of smaller arrays at the specified locations:

The sub-arrays are returned as rows, with empty cells displaying #N/A.
The Numpy help on the function (and most of the other functions in py_Numpy) can be displayed by clicking on ‘Help on this function’ in the bottom-left corner of the function dialog box:

Pingback: py_Numpy update 2: Polynomial functions | Newton Excel Bach, not (just) an Excel Blog