About 805,000 results
Open links in new tab
  1. Python | Using 2D arrays/lists the right way - GeeksforGeeks

    Jun 20, 2024 · Python lists are dynamic and versatile, making them an excellent choice for representing 1D arrays. Let's start by looking at common ways of creating a 1d array of size N …

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

    Sep 25, 2012 · convert a 1-dimensional array into a 2-dimensional array by adding new axis. a=np.array([10,20,30,40,50,60]) b=a[:,np.newaxis]--it will convert it to two dimension.

  3. python - Create a 2D list out of 1D list - Stack Overflow

    I am a bit new to Python and I want to convert a 1D list to a 2D list, given the width and length of this matrix. Say I have a list=[0,1,2,3] and I want to make a 2 by 2 matrix of this list. How can I …

  4. python - How to define a two-dimensional array? - Stack Overflow

    Jul 12, 2011 · Here are some other ways to create 2-d arrays and matrices (with output removed for compactness): numpy.arange(25).reshape((5, 5)) # create a 1-d range and reshape

  5. Convert a 1D array to a 2D Numpy array - GeeksforGeeks

    Sep 8, 2022 · This package consists of a function called numpy.reshape which is used to convert a 1-D array into a 2-D array of required dimensions (n x m). This function gives a new required …

  6. How To Create A 2D Array In Python? - Python Guides

    Jan 1, 2025 · Learn how to create a 2D array in Python using nested lists, NumPy, and list comprehensions. This tutorial provides examples for building and managing 2D arrays

  7. Convert 1D array to 2D array in Python (numpy.ndarray, list)

    May 15, 2023 · This article explains how to convert a one-dimensional array to a two-dimensional array in Python, both for NumPy arrays ndarray and for built-in lists list.

  8. Create a 2D NumPy Array in Python (5 Simple Methods)

    May 9, 2025 · Learn 5 practical methods to create 2D NumPy arrays in Python. Perfect for data analysis, with real-world examples using sales data, random initialization, and more

  9. Numpy Step By Step Guide - GeeksforGeeks

    Apr 22, 2025 · NumPy arrays are created using the np.array() function, which converts lists, tuples, or other sequences into a NumPy array. You can create different types of arrays, such …

  10. Array creation — NumPy v2.2 Manual

    The 2D array creation functions e.g. numpy.eye, numpy.diag, and numpy.vander define properties of special matrices represented as 2D arrays. np.eye(n, m) defines a 2D identity matrix.