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

    Jul 12, 2011 · Matrix operations in numpy most often use an array type with two dimensions. There are many ways to create a new array; one of the most useful is the zeros function, …

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

    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 …

  3. 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 …

  4. python - Convert a 1D array to a 2D array in numpy - Stack Overflow

    Sep 25, 2012 · I want to convert a 1-dimensional array into a 2-dimensional array by specifying the number of columns in the 2D array. Something that would work like this: > import numpy …

  5. 2D arrays in Python - Stack Overflow

    In Python one would usually use lists for this purpose. Lists can be nested arbitrarily, thus allowing the creation of a 2D array. Not every sublist needs to be the same size, so that solves your …

  6. python - From ND to 1D arrays - Stack Overflow

    Say I have an array a: a = np.array([[1,2,3], [4,5,6]]) array([[1, 2, 3], [4, 5, 6]]) I would like to convert it to a 1D array (i.e. a column vector): b = np.reshape ...

  7. python - Plotting a 2D heatmap - Stack Overflow

    Oct 16, 2022 · Using Matplotlib, I want to plot a 2D heat map. My data is an n-by-n Numpy array, each with a value between 0 and 1. So for the (i, j) element of this array, I want to plot a …

  8. How do I declare an array in Python? - Stack Overflow

    Oct 3, 2009 · @AndersonGreen As I said there's no such thing as a variable declaration in Python. You would create a multidimensional list by taking an empty list and putting other lists …

  9. How to make a copy of a 2D array in Python? - Stack Overflow

    Jun 30, 2011 · X is a 2D array. I want to have a new variable Y that which has the same value as the array X.Moreover, any further manipulations with Y should not influence the value of the X.

  10. python - How can I make a two-dimensional NumPy array a three ...

    Apr 27, 2024 · I hope this function helps you to convert the two-dimensional array to a three-dimensional array. Args: x: 2darray, (n_time, n_in) agg_num: int, number of frames to …