About 401,000 results
Open links in new tab
  1. python - How to define a two-dimensional array? - Stack Overflow

    Jul 12, 2011 · I want to define a two-dimensional array without an initialized length like this: Matrix = [][] But this gives an error: IndexError: list index out of range

  2. How to initialize a two-dimensional array (list of lists, if not using ...

    @codemuncher The reason that [[0] * col] * row doesn't do what you want is because when you initialize a 2d list that way, Python will not create distinct copies of each row. Instead it will init the outer list …

  3. Two dimensional array in python - Stack Overflow

    2 When constructing multi-dimensional lists in Python I usually use something similar to ThiefMaster's solution, but rather than appending items to index 0, then appending items to index 1, etc., I always …

  4. 2D arrays in Python - Stack Overflow

    3 If you are concerned about memory footprint, the Python standard library contains the array module; these arrays contain elements of the same type.

  5. python - Create a two-dimensional array with two one-dimensional …

    105 If you wish to combine two 10 element one-dimensional arrays into a two-dimensional array, np.vstack((tp, fp)).T will do it. np.vstack((tp, fp)) will return an array of shape (2, 10), and the T …

  6. Simple way of creating a 2D array with random numbers (Python)

    Jun 8, 2014 · I know that an easy way to create a NxN array full of zeroes in Python is with:

  7. How do I create an empty array and then append to it in NumPy?

    I want to create an empty array and append items to it, one at a time. xs = [] for item in data: xs.append(item) Can I use this list-style notation with NumPy arrays?

  8. Create arbitrary multidimensional zeros array - Stack Overflow

    I need to make a multidimensional array of zeros. For two (D=2) or three (D=3) dimensions, this is easy and I'd use: a = numpy.zeros(shape=(n,n)) or a = numpy.zeros(shape=(n,n,n)) How for I for

  9. Python numpy: create 2d array of values based on coordinates

    I want to create a 2D array of values from the third row based on their x,y coordinates in the file. I read in each column as an individual array, and I created grids of x values and y values using …

  10. Efficiently initialize 2D array of size n*m in Python 3?

    Jul 31, 2017 · 6 I am using Python 3 and am trying to create 2D integer arrays of a known and fixed size. How can I do this? The arrays I have in mind are the Python-provided array.array, although I am not …