I have an array Nx3 of N points, each one has X, Y and Z coordinate. I need to rotate each point, so i have the rotation matrix 3×3. To do this, i need to get dot product of the rotation matrix and each point. The problem is the array of points is quite massive (~1_000_000x3) and therefore it takes
Tag: arrays
Is there a way to write a python function that will create ‘N’ arrays? (see body)
I have an numpy array that is shape 20, 3. (So 20 3 by 1 arrays. Correct me if I’m wrong, I am still pretty new to python) I need to separate it into 3 arrays of shape 20,1 where the first array is 20 elements that are the 0th element of each 3 by 1 array. Second array is
Appending an empty list to a numpy array changes its dtype
I have a numpy array of integers. In my code I need to append some other integers from a list, which works fine and gives me back an array of dtype int64 as expected. But it may happen that the list of integers to append is empty. In that case, numpy returns an array of float64 values. Exemplary code below:
python) update value of array in dictionary and update it
I want to update ‘array’ inside the dictionary after doing interpolation. for example, “array_ex” is a dictionary and has values like below and ‘0_array’ has (6,100) shape while ‘1_array’ has (6,200) shape… I wrote a function for interpolating the array using np.interp. The function interpolates the shape of array (6,100) to (6,200). However, how can I update my array after
python print array inside the dictionary
I want to print ‘array’ inside the dictionary but my code gives me ‘each value’ of the array. for example, “array_ex” is a dictionary and has values like below with 12 rows for each array… and I want to get each row of the array as a result. However, my code returns each value of the array. How can I
How to get this result when multiplying 1d-array by 2d-array?
I am struggling to figure out, how the output is calculated can you please explain? I have this multiplied by this array : c = np.array([3267. , 3375.9, 3484.8, 3630., 3740.]) the output is: array([1050885., 1068309., 1085733., 1103157., 1120581.]) Answer Grasping at straws because it feels like there’s not enough information to solve this. But, here is one way to
Mongo db array of images change schema
I have an array of images in mongodb and I am trying to change the schema of the array. Right now the images are stored like bellow And the final output I want is like bellow. How can I do this in mongosh? Is it easier to do this as a Python Array and then import back to mongodb? Thank
Replace value based on a corresponding value but keep value if criteria not met
Given the following dataframe, INPUT df: Cost_centre Pool_costs 90272 A 92705 A 98754 A 91350 A Replace Pool_costs value with ‘B’ given the Cost_centre value but keep the Pool_costs value if the Cost_centre value does not appear in list. OUTPUT df: Cost_centre Pool_costs 90272 B 92705 A 98754 A 91350 B Current Code: This code works up until the else
IndexError: shape mismatch: indexing arrays could not be broadcast together with shapes (2,) (3,)
I have an np.ndarray of shape (5, 5, 2, 2, 2, 10, 8) named table. I can succesfully slice it like this: But for some reason when I try to specify three values for dimension 5 (of length 10) like this: I get: The same is for: This does not happen with: which output the correct result. I tried to
3d numpy array perform operation along column i only
I have a 3d numpy array like this (as an example) I want to apply the following operations only to elements within the column with index 1 in the inner dimension. The elements are [-2,6,10,14] for the example above. The operations would be: Can someone help me? I have looked into several NumPy methods but can’t seem to adapt to