Questions tagged [numpy-ndarray]

Numpy Ndarray refers to the N-dimensional array type that describes the collection of the same type in the Python library NumPy. Use this tag for questions related to this array type.

Numpy Ndarray refers to the N-dimensional array type that describes the collection of the same type in the Python library NumPy.

https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html

3757 questions
1
vote
0 answers

Performance decreases with increasing nesting of array elements

A short note: This question relates to another I asked previously, but since asking multiple questions within a single Q&A is concidered bad SO-style I splitted it up. Setup I have the following two implementations of a matrix-calculation: The…
Markus
  • 2,265
  • 5
  • 28
  • 54
1
vote
0 answers

Array to cv2 frame in Python multiprocessing

I have gstreamer buffer and like to convert to cv2 frame in python multiprocessing Gstreamer gets buffer from camera in one process and buffer is passed to another process using Multprocessing.Array Gstreamer gets buffer in one process as …
batuman
  • 7,066
  • 26
  • 107
  • 229
1
vote
2 answers

Couple elements in numpy array

I have 1-dimensional numpy array (arr0) with different values. I want to create a new array of elements, where each element is a couple (indexes and/or values) of one element to its closest one, considering that the absolute value of the difference…
Sav
  • 142
  • 1
  • 17
1
vote
1 answer

TypeError: 'numpy.ndarray' object is not callable, TypeError: unsupported operand type(s) for /: 'int' and 'list'

So basically I have multiple arrays and I need to calculate something with these arrays. The problem is that some of these arrays sometimes equal zero and are divisors. I want to solve this problem by filtering my array and saying something like…
1
vote
0 answers

Need help in optimising moving window entropy calculations

I am trying to calculate the entropy of 3D patches with sliding windows from a larger 3D array. I can't seem to find a way of optimising the code to run with any reasonable speed. My current working approach uses nested for loops taking each coord…
1
vote
1 answer

From Dbf to numpy array

How can I convert a dbf to numpy array without using arcpy? I tried using the dbf library, but I didn't figure out how to select specific columns from my dbf to build the adequate numpy array. Here is the script I want to reproduce without using…
Nour
  • 117
  • 1
  • 2
  • 10
1
vote
1 answer

Python: Adding values of numpy ndarray to existing pandas Dataframe

I have a cheminformatics dataset(input data) with row id as index and the encoder function is converting my smile string into a binary number in the form of an numpy ndarray. I want to add another column to my input dataframe as the fingerprint but…
nurlubanu
  • 71
  • 1
  • 1
  • 5
1
vote
2 answers

Duplicate every value in array as a new array

I have an numpy ndarray input like this [[T, T, T, F], [F, F, T, F]] and I want to duplicate every value as a new array, so the output would be [[[T,T], [T,T], [T,T], [F,F]] [[F,F], [F,F], [T,T], [F,F]]] How can I do this? Thank you in advance
ErgiS
  • 223
  • 2
  • 10
1
vote
1 answer

How to search for number of values greater than given values for each row

For example, a = np.array([[1,2,3] [1,0,4] [2,1,1]]) and then for each row I would find the number of values greater than a corresponding value in another array, say b = np.array([2,1,0]), and the expected result is an…
Tony
  • 1,225
  • 3
  • 12
  • 26
1
vote
4 answers

Does iloc[ :, 1:2 ]. values and .iloc[ :, 1].values work differently?

If I slice a pandas dataframe with dataset.iloc[:, 1:2].values, it's giving me a 2 dimensional(matrix) structured data where dataset.iloc[:, 1].values is giving me 1 dimensional data. So, my doubt is iloc[:,1:2] & iloc[:,1] dont do the same thing…
Soumen Das
  • 31
  • 1
  • 7
1
vote
1 answer

Function call with np.ndarray say "TypeError: missing 1 required positional argument: "

I'm writing the code to rotate matrix(1x3) on Python 3.5.2. To rotate matrix, I made a function.(Not a Class) def rotate_rpy(posvec: Vector, rotvec: Vector) -> Vector : return np.dot(np.dot(np.dot (posvec, rotate_rpy(rotvec[0]) ),…
yasu80
  • 11
  • 2
1
vote
1 answer

Iterating over ndarray columns in C/C++

How would one get a view of a PyArrayObject* similar to the following python code? # n-column array x # d is the length of each column print(x.shape) # => (d, n) by_column = [x[::,i] for i in range(x.shape[1])] assert len(by_column) ==…
Martmists
  • 152
  • 1
  • 6
1
vote
1 answer

I am trying slicing but I have the following error message: slice indices must be integers or None or have an __index__ method

I am trying slicing but I have the following error message: slice indices must be integers or None or have an __index__ method descriptors = numpy.fft.fftshift(descriptors) center_index = len(descriptors) / 2 descriptors = descriptors[center_index -…
UM_Hasan
  • 3
  • 3
1
vote
1 answer

Changing column datatype from Timestamp to datetime64

I have a database I'm reading from excel as a pandas dataframe, and the dates come in Timestamp dtype, but I need them to be in np.datetime64, so that I can make calculations. I am aware that the function pd.to_datetime() and the…
1
vote
1 answer

Opencv: Numpy array made of zero only while image is captured

I am using Python 3.7.3 and I am trying to initiate to OpenCV and video capture and modification. But I am stuck with following problem: When I run the code below, my webcam data are well captured and displayed in imshow window but I am not able to…
Patinside
  • 13
  • 3