Category "numpy"

Numpy mask based on if a value is in some other list

I have searched high and low and just can't find a way to do it. (It's possible I was searching for the wrong terms.) I would like to create a mask (eg: [True F

Reading coef value from OLS regression results

I use pandas and statsmodels to do linear regression. However, i can't find any possible way to read the results. the results are displayed but i need to do som

How to fix Python Numpy/Pandas installation?

I would like to install Python Pandas library (0.8.1) on Mac OS X 10.6.8. This library needs Numpy>=1.6. I tried this $ sudo easy_install pandas Searching

How to find all neighbors of a given point in a delaunay triangulation using scipy.spatial.Delaunay?

I have been searching for an answer to this question but cannot find anything useful. I am working with the python scientific computing stack (scipy,numpy,matp

Adding a vector to matrix rows in numpy

Is there a fast way in numpy to add a vector to every row or column of a matrix. Lately, I have been tiling the vector to the size of the matrix, which can use

How to invert a permutation array in numpy

Given a self-indexing (not sure if this is the correct term) numpy array, for example: a = np.array([3, 2, 0, 1]) This represents this permutation (=> is

python read zipfile into numpy-array efficiently

I want to read a zipfile into memory and extract its content into a numpy array (as numpy-datatypes). This needs to happen in an extremely efficient/fast manner

NumPy: get min/max from record array of numeric values

I have a NumPy record array of floats: import numpy as np ar = np.array([(238.03, 238.0, 237.0), (238.02, 238.0, 237.01), (238.05

numpy mean of complex numbers with infinities

numpy seems to not be a good friend of complex infinities While we can evaluate: In[2]: import numpy as np In[3]: np.mean([1, 2, np.inf]) Out[3]: inf The f

Python Numpy: replace values in one array with corresponding values in another array

I am using Python Numpy arrays (rasters converted to 2D arrays, specifically) and what I want to do is take one array that has arbitrary dummy values of -999 re

Adding row/column headers to NumPy arrays

I have a NumPy ndarray to which I would like to add row/column headers. The data is actually 7x12x12, but I can represent it like this: A=[[[0, 1, 2, 3, 4, 5]

How to display a text with matplotlib

I would like to do this : I have this python code : import numpy as np import pylab as plt a = np.array([1,2,3,4,5,6,7,8,9,10]) b = np.array([7,8,6,3,2,1,5,8,4

Linear index upper triangular matrix

If I have the upper triangular portion of a matrix, offset above the diagonal, stored as a linear array, how can the (i,j) indices of a matrix element be extrac

numpy's interp function - how to find a value of x for a given value of y?

So I have an array of values of x (in increasing order) and the corresponding y values. Numpy's interp function takes in the X value, and the x and y arrays. Ho

Logical indexing - numpy.where in C++

I have created a simple numpy array with shape (4, 2) called A. import numpy as np A = np.array([[1, 2], [2, 2], [3, 2],

PyArray_Check / PyArray_CheckExact gives segmentation fault

In c++, I define the following module: #include <boost/python.hpp> #include <numpy/arrayobject.h> bool foo(PyObject *obj) { if (!PyArray_Check

AttributeError: 'MachAr' object has no attribute 'smallest_subnormal'

When importing librosa library, this error has occurred. C:\Users\jssong\anaconda3\envs\tensor_v2\lib\site-packages\numpy\core\getlimits.py:492: UserWarning: Si

Python poetry install failure - invalid hashes

I'm unsure exactly what information / context to provide with this post in order for it to be properly answered - so if I can add more information please let me

Numpy argmax - random tie breaking

In numpy.argmax function, tie breaking between multiple max elements is so that the first element is returned. Is there a functionality for randomizing tie brea

Upsample and Interpolate a NumPy Array

I have an array, something like: array = np.arange(0,4,1).reshape(2,2) > [[0 1 2 3]] I want to both upsample this array as well as interpolate the re