Alright, I'm toying around with converting a PIL image object back and forth to a numpy array so I can do some faster pixel by pixel transformations than PIL's PixelAccess object would allow. I've figured out how to place the pixel information in a usefu...

Asked By akdom

Is there a convenient way to calculate percentiles for a sequence or single-dimensional numpy array?
I am looking for something similar to Excel's percentile function.
I looked in NumPy's statistics reference, and couldn't find this. All I could find is...

Asked By Uri

Let's say I have a 1d numpy array
a = array([1,0,3])
I would like to encode this as a 2d 1-hot array
b = array([[0,1,0,0], [1,0,0,0], [0,0,0,1]])
Is there a quick way to do this? Quicker than just looping over a to set elements of b, that is.

Asked By James Atwood

I have two simple one-dimensional arrays in NumPy. I should be able to concatenate them using numpy.concatenate. But I get this error for the code below:
TypeError: only length-1 arrays can be converted to Python scalars
Code
import numpy
a = numpy...

Asked By highBandWidth

NumPy proposes a way to get the index of the maximum value of an array via np.argmax.
I would like a similar thing, but returning the indexes of the N maximum values.
For instance, if I have an array, [1, 3, 2, 4, 5], function(array, n=3) would return t...

Asked By Alexis Métaireau

What are the advantages of NumPy over regular Python lists?
I have approximately 100 financial markets series, and I am going to create a cube array of 100x100x100 = 1 million cells. I will be regressing (3-variable) each x with each y and z, to fill the...

Asked By Thomas Browne

In Python, how do I create a numpy array of arbitrary shape filled with all True or all False?

Asked By Michael Currie