multidimensional « numpy « Python Data Type Q&A

Home
Python Data Type Q&A
1.array
2.date
3.dictionary
4.Format
5.integer
6.List
7.numpy
8.regex
9.string
10.tuple
Python Data Type Q&A » numpy » multidimensional 

1. Iterating through a multidimensional array in Python    stackoverflow.com

I have created a multidimensional array in Python like this:

self.cells = np.empty((r,c),dtype=np.object)
Now I want to iterate through all elements of my twodimensional array, and I do not care about the order. ...

2. Using numpy to build an array of all combinations of two arrays    stackoverflow.com

I'm trying to run over the parameters space of a 6 parameter function to study it's numerical behavior before trying to do anything complex with it so I'm searching for a ...

3. Multidimensional list(array) reassignment problem    stackoverflow.com

Good day coders and codereses, I am writing a piece of code that goes through a pile of statistical data and returns what I ask from it. To complete its task the ...

4. Simple question: In numpy how do you make a multidimensional array of arrays?    stackoverflow.com

Right, perhaps I should be using the normal Python lists for this, but here goes: I want a 9 by 4 multidimensional array/matrix (whatever really) that I want to store arrays in. ...

5. Python: Error --> setting an array element with a sequence    stackoverflow.com

The data-element is a float-number and no sequence (I think). But I get the error "setting an array element with a sequence".

folder = r"C:\Dokumente und Einstellungen\ssc"
contents=os.listdir(folder)

ar = zeros((81,81,256),int)
filenumber = 0

for d ...

6. Slice a 2D Python Array    stackoverflow.com

I have a 2d array in the numpy module that looks like:

data = array([[1,2,3],
              [4,5,6],
    ...

7. How to write a multidimensional array to a text file?    stackoverflow.com

In another question, other users offered some help if I could supply the array I was having trouble with. However, I even fail at a basic I/O task, such as writing ...

8. Where do two 2-D arrays begin to overlap each other?    stackoverflow.com

I'm working with model output at the moment, and I can't seem to come up with a nice way of combining two arrays of data. Arrays A and B store ...

9. Numpy: Concatenating multidimensional and unidimensional arrays    stackoverflow.com

I have a 2x2 numpy array :

x = array(([[1,2],[4,5]]))
which I must merge (or stack, if you wish) with a one-dimensional array :
y = array(([3,6]))
by adding it to the end of the ...

10. Autocorrelation of a multidimensional array in numpy    stackoverflow.com

I have a two dimensional array, i.e. an array of sequences which are also arrays. For each sequence I would like to calculate the autocorrelation, so that for a (5,4) array, ...

11. slicing 2d numpy array    stackoverflow.com

I have a 2d numpy array called FilteredOutput that has 2 columns and 10001 rows, though the number of rows is a variable. I am trying to take the 2nd column of ...

12. Indexing numpy array with another numpy array    stackoverflow.com

Suppose I have

a = array([[1, 2],
           [3, 4]])
and
b = array([1,1])
I'd like to use b in index a, that is to ...

13. Selecting from multidimensional numpy array    stackoverflow.com

I have a multidimensional array a with shape (nt, nz, ny, nx). The dimensions are time, z, y, x. For each time, x and y, I've selected the appropriate z in ...

14. Using numpy.argmax() on multidimensional arrays    stackoverflow.com

I have a 4 dimensional array, i.e., data.shape = (20,30,33,288). I am finding the index of the closest array to n using

index = abs(data - n).argmin(axis = 1), so
index.shape = ...

15. Passing a numpy array to Delphi dll    stackoverflow.com

I am trying to implement an image classification algorithm in Python. The problem is that python takes very long with looping through the array. That's why I decided to write a ...

16. How can I turn a list into an array in python?    stackoverflow.com

How can I turn a list such as:

data_list = [0,1,2,3,4,5,6,7,8,9]
into a array (I'm using numpy) that looks like:
data_array = [ [0,1] , [2,3] , [4,5] , [6,7] , [8,9] ]
Can I ...

17. Mapping a numpy array in place    stackoverflow.com

Is it possible to map a numpy array in place? If yes, how? Given a_values - 2D array - this is the bit of code that does the trick for me at ...

18. NumPy: array assignment issue when using custom dtype    stackoverflow.com

I've found the following puzzling behavior with NumPy and a custom dtype for an ndarray:

import numpy as np

# Make a custom dtype with a single triplet of floats (my actual dtype ...

19. Numpy multidimensional array slicing    stackoverflow.com

Suppose I have defined a 3x3x3 numpy array with

x = numpy.arange(27).reshape((3, 3, 3))
Now, I can get an array containing the (0,1) element of each 3x3 subarray with x[:, 0, 1], which ...

20. How to make a 2d numpy array a 3d array?    stackoverflow.com

I have a 2d array with shape (x, y) which I want to convert to a 3d array with shape (x, y, 1). Is there a nice Pythonic way to do ...

21. Calculating cumulative returns in Numpy, problem with array indices    stackoverflow.com

I am new to using the numpy class and I am having problems with manipulating the contents of the array. Here is the code:

# finance equation to apply to each element ...

22. Concatenate Numpy arrays without copying    stackoverflow.com

In Numpy, I can concatenate two arrays end-to-end with np.append or np.concatenate:

>>> X = np.array([[1,2,3]])
>>> Y = np.array([[-1,-2,-3],[4,5,6]])
>>> Z = np.append(X, Y, axis=0)
>>> Z
array([[ 1,  2,  3],
   ...

23. Numpy: how to assign values to individual elements of multidimensional arrays?    stackoverflow.com

I'm working with 3-dimensional arrays (for the purpose of this example you can imagine they represent the RGB values at X, Y coordinates of the screen).

>>> import numpy as np
>>> a ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.