Category "numpy"

Getting error while generating heatmap in python:ValueError: Must pass 2-d input. shape=()

I am getting errors while generating maps of h3 moments in python for an image file called "image_test". The error apparently is for the shape of the values tha

Signal correlation shift and lag correct only if arrays subtracted by mean

If I have two arrays that are identical except for a shift: import numpy as np from scipy import signal x = [4,4,4,4,6,8,10,8,6,4,4,4,4,4,4,4,4,4,4,4,4,4,4] y =

How to create a new columns based off of values of other columns which could contain #s or NaN?

I have a few dataframes that I'm merging based on known, populated fields. The resulting dataframe will always contain a set of columns, but may or may not have

Creating multiple figures out of for loop

I am trying to loop through my table and to create 3 different figures. This is my code .... tab_stat = pd.read_table('test.txt', delim_whitespace=True) radius

ValueError: num must be 1 <= num <= 5, not 0 error

I am stuck with this code written in py2 on psychopy. I am not an expert with coding. I am trying to run the function "analyzeStaircases(stairs, stairInfo['Aver

What is a rank 1 array in Numpy

Consider the following vector: import numpy as np u = np.random.randn(5) print(u) [-0.30153275 -1.48236907 -1.09808763 -0.10543421 -1.49627068] When we print

If no conditions are met, how do I raise a value error with np.select?

Working with human labeled data, I have four cases that cover correct behavior, but it is possible for annotators to miss the need to provide a value. When this

C-API register a ufunc loop against builtin ufunc

I am looking to build a numpy extension module which declares a new structured dtype and provides the necessary inner ufunc loops to allow built-in math operati

Finding the shortest path to solve colored water sorting games

So my aunt plays this now popular mobile game, shown in the picture below. She got stuck on a certain level and asked me if I can solve it. Knowing that I'm not

prevent numpy stack method change INT data to float

I try to stack three one dimension array. a and b are int that can be work as index and c is float. After I stack this three with axis=0, the a and b data chang

Tensorflow dataset element shuffle within specified range

How do I shuffle the elements of tf.data.Dataset within a certain range. Having an input array, with shape = (10,), in the first 5 elements would be shuffled wi

How to remove 2d array from 3d array if it contains NA values

I am working on a seq2seq machine learning problem with Conv1D and LSTM, to do this I must produce a tensor input of the shape samples, timesteps, features. Asi

How to generate numpy arrays with random regions with rectangular shape with random size?

I would like to generate a binary array (values are 1s and 0s) filled with rectangular regions. Something like this: a = np.array([0, 1, 1, 0, 0] [

Add a new logic in pyhton

Want to add logic that calculates and outputs truckloads able to be built each day. Still want this broken out by ship-to party (so 1 ship-to party per shipment

How to optimize the downlaod big file problem in Django?

My Django project gives a download interface as follows: def download_item_vector(request): return HttpResponse(np.load('item_vector.npy')) I want to retur

Encountering divide by zero after a conditional preventing this

I am writing a simple piece of code for a physics assignment where we are supposed to model a water molecule as a collection of charged particles. I am supposed

Eigenanalysis of complex hermitian matrix: different phase angles for EIG and EIGH

I understand that eigenvectors are only defined up to a multiplicative constant. As far as I see all numpy algorithms (e.g. linalg.eig, linalg.eigh, linalg.svd)

Python Numpy: Replacing index with index from other array if zero

I am trying to merge some depth data frames, captured with a Intel realsense depth camera. The depth data frames comes in the following format: dataframe1 = [[0

Error "Numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject."

I got this error file while following this tutorial: https://www.youtube.com/watch?v=yqkISICHH-U So far I have created a training dataset to feed into Tensorflo

How to make a vector of matrices in numpy

I would like to create a vector of the same matrix in numpy (so as an array). Let's say the matrix is: w = np.array([[1,2], [3,4], [