Skip to main content
Filter by
Sorted by
Tagged with
-1 votes
1 answer
2k views

I came across a weird behavior with numpy, for which I do not have a good explanation. In one function, I do some operations on a copied numpy array. There is no issue when I run this code once. ...
Oliver's user avatar
  • 84
0 votes
1 answer
76 views

Say I have a 4x4 array, each row already sorted by smallest value. I want to create a list with the minimum values from each array row without repeating a value. So if a minimum value is already in ...
n_cen's user avatar
  • 5
0 votes
1 answer
445 views

I am working with nd arrays which contain coordinate data for multiple contours in [x, y, z] space. I am trying to add x, y, and z offsets to the lines based on other conditions. The offsets will be ...
Patman521's user avatar
0 votes
1 answer
143 views

I always get find myself in state of confusion when dealing with a multi-dimensional array. Imaging having the following array of arrays, where each array contains feature importance scores (3-...
Amina Umar's user avatar
1 vote
1 answer
113 views

I need to calculate a moving average over a 3D array with a step size set by me. What I am doing right now is img = np.ones(10,10,50) img_new = bottleneck.move.move_mean(img, window=5, axis=2) ...
emely_pi's user avatar
  • 701
0 votes
2 answers
94 views

I have the following array of shape (A, B) where A=4 and B=2 here: [[1 1] [2 2] [3 3] [4 4]] I want to modify the array so each row consists of randomly selected values from the other rows, with no ...
Anne's user avatar
  • 3
0 votes
0 answers
52 views

In below example x is view of y. Why id(x[1,1]) and id(y[1,1]) are different? I experimented with array views, but I don't understand how it works. import numpy as np x=np.array([[1,2,3],[4,5,6],[7,8,...
pythonist_newbie's user avatar
0 votes
1 answer
50 views

I have an array of points: centers = array([0,0,0,0], [0,1,0,0], [0,0,0,1], [1,0,0,0]) Using scikit.ndimage.distance_transform_edt(), the index ...
shawkra's user avatar
0 votes
1 answer
123 views

I am considering arrays of shape (n,2) for arbitrary n. I want to check whether the two-element sub-arrays match. As an example: import numpy as np a=np.array([[1,0],[2,0]]) b=np.array([[1,0],[2,0]]) ...
jore1's user avatar
  • 5
0 votes
1 answer
936 views

When using load_dataset() to load a Mozilla Common Voice (v11) dataset, the resulting dataset (ds) has audio.arrays as numpy arrays. I don't know how to reproduce this. How do you set just one feature ...
Jaggz's user avatar
  • 21
0 votes
2 answers
110 views

I have an multidimensional ndarray of tuples, which further consists of two elements - first is another array and second is a dict. I am after the first element of each of these tuples. Basically make ...
lattitude's user avatar
  • 157
0 votes
1 answer
494 views

I have a picture of a simple black and white mandala. I'm using Python and cv2 and numpy. My goal is to get the contour as X, Y coordinates and save them in a gcode file. The problem is that I get as ...
ALMR00's user avatar
  • 1
0 votes
0 answers
72 views

Here is the 2 files. I am getting error in train_model.py file while using the fit method Model.py def alexnet(width,height,outputs,lr): model = Sequential() model.add(Conv2D(filters=64, ...
Saswat Behera's user avatar
0 votes
1 answer
314 views

sosfilt from the scipy=1.9.3 library is giving me a strange ValueError when inputting a numpy=1.23.4 array. MWE: import numpy as np from scipy.signal import sosfilt fs=48000 rng = np.random....
Mike's user avatar
  • 67
0 votes
1 answer
225 views

The following code works fine to insert multidimensional numpy arrays into a table def adapt_numpy_array(numpy_array): return AsIs(numpy_array.tolist()) register_adapter(np.ndarray, ...
Tengrath's user avatar
3 votes
0 answers
349 views

I've been trying to use a number of clustering techniques on an extremely large image dataset (around 1 million images). The process is quite standard - e.g., using a pretrained CNN (VGG19 in this ...
vmchance's user avatar
0 votes
2 answers
165 views

My apologies if I haven't phrased this properly. I have an array of ~10^7 monotonically increasing elements: example_array = np.array([10, 10.5, 13, 15, 20, 35, 37.1, 40, 50]) I'd like to find the ...
Diego's user avatar
  • 60
1 vote
1 answer
138 views

I have a function x as shown below that takes two numpy arrays as the input and I want to get back a boolean value upon some computation. import numpy as np def x(a,b): print(a) print(b) #...
Devarapalli Vamsi's user avatar
-1 votes
2 answers
163 views

So I have a 2D Numpy array i want to modify with classical conditional indexing: array[array>threshold] = np.nan But i want to implement a conditional that utilizes the index of the element, so as ...
E. Gptreas's user avatar
0 votes
2 answers
56 views

This script creates an array b of indices and values of given array a, which is useful for example in conversion of 2.5D height map to a point cloud: import numpy as np a = np.arange(12).reshape(3, 4)...
Paul Jurczak's user avatar
  • 8,628
1 vote
1 answer
74 views

This Python script: import numpy as np a = np.random.rand(8, 8) b = np.full_like(a, -1) n = 0 for i, val in np.ndenumerate(a): if val < 0.666: b[i] = n n += 1 creates array b with ...
Paul Jurczak's user avatar
  • 8,628
0 votes
1 answer
529 views

I am trying to test batches in my training set. My training set is in a .tsv file with 3 columns: Quality( 1 indicates the two sentences are similar and 0 is the opposite), #1 String (1st String), #2 ...
A Random Guy's user avatar
-1 votes
1 answer
97 views

I am having trouble slicing the below NumPy array. I want to pull out the first column. I have tried almost every combination and cannot slice the column I want; it always slices the row. print(...
remusconnor's user avatar
-1 votes
3 answers
115 views

in a numpy array , I have to print out elements when the difference between elements is > or < 1 Basically it should print the element when the difference is > or < 1 Input : arr=np.array([...
Kapil's user avatar
  • 325
0 votes
3 answers
80 views

I try to use numpy to fast text analysis. Exactly to collocations analysis. Let's suppose I have the following string which I converted into a numpy array: text = np.array(['a', 'b', 'c', 'd', 'e', 'b'...
jback's user avatar
  • 11
1 vote
1 answer
339 views

Let's say I have a 0d Numpy array: x = numpy.asarray(1.) This has type numpy.ndarray. But now operate on x: y = 1.*x This now has type numpy.float64. The same thing is true when using all Numpy ...
argentum_109's user avatar
1 vote
1 answer
167 views

I am a beginner at using Python code, and I have a problem with calculating the RMSE in two matrixes when they include Nan values. For example, I have two matrixes, which include a couple of columns ...
pay mia's user avatar
  • 13
0 votes
1 answer
72 views

I have two matrices A and B of dimensions (n_m, n_u) and (n_m, n). I want a 3D matrix with dimensions (n, n_m, n_u) such that the first column of B is multiplied (element-wise) with every column of A ...
Shashwat Gupta's user avatar
1 vote
3 answers
1k views

I'm trying to find unique pixels in a numpy ndarray of shape 400, 800, 3. I can get exactly what I want with np.unique(im.reshape(-1, 3), axis=0) however np.unique is too slow for my application ...
Octa's user avatar
  • 129
0 votes
3 answers
220 views

Consider two arrays A and B, both of dimension NxN. I wish to generate a new array NxN such that each new element is a tuple (or list, doesn't really matter) of the type (A_ij,B_ij). I can do it by ...
delta_omega's user avatar
1 vote
0 answers
37 views

I was working on a code and noticed that numpy indexing and slicing doesn't work as I expected. For example, x = np.random.randn(1,5,3,4) y = x[0, :, :, [1,2]] y.shape I expected y.shape to be (5,3,2)...
Hajin Lee's user avatar
  • 199
0 votes
1 answer
42 views

I have an array like so: data = np.array([ [[10, 10, 10], [10, 10, 10], [10, 10, 10]], [[20, 20, 20], [20, 20, 20], [20, 20, 20]], [[30, 30, 30], [30, 30, 30], ...
Edy Bourne's user avatar
  • 6,306
1 vote
1 answer
120 views

I am having a Problem with the np.append and np.vstack I am trying to combine a 48x48 grayscale face image with an array of the landmarks from the face. So I can have an Array with the images and the ...
Alexander's user avatar
2 votes
3 answers
125 views

I was testing a code in the console and got this: >>> import numpy as np >>> np.arange(0.6, 0.68, 0.01) array([0.6 , 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68]) >>> np....
jhhuang's user avatar
  • 21
1 vote
1 answer
7k views

My outputs T_results and c_results have values of 0 at the end, which I do not want so I sliced theses arrays excluding their last column and got their respective arrays T_results_cleaned = T_results[:...
NGA's user avatar
  • 45
1 vote
3 answers
471 views

I have image data that is represented with 10 or 12-bit integers and I would like to save this data to disk without writing the unnecessary 6 or 4 zeros of padding when using 16-bit integer to ...
Daniel Konečný's user avatar
1 vote
0 answers
171 views

I'm using np.savez_compressed() to compress and save a single large 4D NumPy array, but it uses only one CPU core. Is there an alternative, which can use many cores? Preferably something simple ...
Paul Jurczak's user avatar
  • 8,628
0 votes
0 answers
42 views

I have an array of pairs of size (N,2), and I want to convert them to tuples to be able to perform an isin operation. I tried using view, but it doesn't seem to work: coo = np.array([[1,2],[1,6],[5,3],...
David Davó's user avatar
1 vote
0 answers
119 views

PROBLEM Let's say I have a python script that works with a numpy ndarray and then pickle.dumps it into bytes. Another python script would then pickle.loads those bytes and see the object as a numpy ...
FV_at_Alst's user avatar
3 votes
2 answers
412 views

I have two arrays of different sizes and want to determine where elements of one array can be found in the other array. I would like to be able to allow for a tolerance between elements. The goal ...
celery's user avatar
  • 43
1 vote
1 answer
103 views

I have a question very similar to this post. Essentially I start with 2 2d arrays(of possibly different width), with a bunch of rows where the leftmost column acts as an effective index and I would ...
Alosapien's user avatar
1 vote
2 answers
45 views

What I have is an array of numpy arrays (a 2d numpy array). my_array = [ [1, 2, 3, 4] [1, 2, 3, 4] [2, 3, 4, 5] [2, 3, 4, 5] ] and I want to turn it into: ...
wallstalk's user avatar
  • 103
4 votes
2 answers
59 views

import numpy as np # Create two sample dataframes df1 = np.array([[0.000000,0.000000,0.000000], [0.090000,0.000000,0.000000], [0.190000,0.000000,0.000000], [0.280000,0.000000,0.000000], [0.380000,0....
jiaming li's user avatar
-1 votes
1 answer
486 views

I have the following line of code given to me as part of an example in my python course np.sqrt(1.-np.arange(0,1.01,0.01)**2) But there have been no explanations given. I am confused as to what the ...
Despaxir's user avatar
0 votes
1 answer
66 views

A represents tasks that need to be processed on each machine. A total of 5 tasks are given T0 to T4. B are the Setup values required to prepare a machine for processing a task that has been added ...
Arunmozhi's user avatar
0 votes
1 answer
44 views

I thought this was an easy problem, but I have been struggling with it. I have a dataframe with 4 columns (Open, High, Low, Close). I need to iteratively select for 100 times a batch of 75 rows each ...
user1517108's user avatar
  • 2,425
1 vote
1 answer
69 views

Using NumPy, given a and a smaller boolean array b: a = np.array([False, True, True, False, True]) b = np.array([False, True, False]) how to obtain result c? c = np.array([False, False, True, False, ...
Sengiley's user avatar
  • 289
0 votes
2 answers
230 views

As a newbie in python I want to populate a list with images, in form of arrays. If I add elements, they overwrite the existing values. How can I add elements into a list? Example code: import numpy as ...
Widhold's user avatar
  • 38
0 votes
2 answers
276 views

I have a script which reads a video frame by frame and accumulate them in a deque. labeled_frame_dequeue = [numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray] I am trying to pass this list ...
raj-kapil's user avatar
  • 477
1 vote
1 answer
165 views

This is my NumPy array: og_arr = [['5mm', '45"', '300 mm WT', 'Nan'], ['50mm', '3/5"', 'Nan', 'Nan']] I have written some logic that is able to identify at which index position the mm/inch ...
Lihka_nonem's user avatar

1
3 4
5
6 7
79