
Most efficient way to map function over numpy array
Feb 5, 2016 · What is the most efficient way to map a function over a numpy array? I am currently doing: import numpy as np x = np.array([1, 2, 3, 4, 5]) # Obtain array of square ...
python - Is there a NumPy function to return the first index of ...
Jan 11, 2009 · One can safely assume that the index() function in Python is implemented so that it stops after finding the first match, and this results in an optimal average performance. For …
What does the .numpy() function do? - Stack Overflow
Sep 19, 2020 · numpy() -> numpy.ndarray Returns :attr:`self` tensor as a NumPy :class:`ndarray`. This tensor and the returned :class:`ndarray` share the same underlying storage. Changes to …
Numpy apply function to every item in array - Stack Overflow
Jul 13, 2020 · How can I apply a function to every single item in the array and replace that item with the return? Also, the function's return will be a tuple, so the array will become 3d.
python - Is there any numpy group by function? - Stack Overflow
Jun 24, 2016 · 153 Is there any function in numpy to group this array down below by the first column? I couldn't find any good answer over the internet..
How do you do natural logs (e.g. "ln()") with numpy in Python?
Using numpy, how can I do the following: ln(x) Is it equivalent to: np.log(x) I apologise for such a seemingly trivial question, but my understanding of the difference between log and ln is that ...
NumPy: function for simultaneous max () and min ()
176 numpy.amax () will find the max value in an array, and numpy.amin () does the same for the min value. If I want to find both max and min, I have to call both functions, which requires …
Using NumPy to build an array of all combinations of two arrays
216 I'm trying to run over the parameters space of a six-parameter function to study its numerical behavior before trying to do anything complex with it, so I'm searching for an efficient way to …
How can I calculate a rolling / moving average using Python
253 There doesn’t seem to be any function in NumPy or SciPy that simply calculate the moving average, leading to convoluted solutions. My question is twofold: What's the easiest way to …
python - numpy max vs amax vs maximum - Stack Overflow
Nov 6, 2015 · 220 numpy has three different functions which seem like they can be used for the same things --- except that numpy.maximum can only be used element-wise, while …