How to convert 1-D arrays as columns into a 2-D array in Python? Last Updated : 13 Jan, 2021 Comments Improve Suggest changes Like Article Like Report Let's see a program to convert 1-D arrays as columns into a 2-D array using NumPy library in Python. So, for solving this we are using numpy.column_stack() function of NumPy. This function takes a sequence of 1-D arrays and stack them as columns to make a single 2-D array. Syntax : numpy.column_stack(tuple) Parameters : tup : [sequence of ndarrays] Tuple containing arrays to be stacked. The arrays must have the same first dimension. Return : [stacked 2-D array] The stacked 2-D array of the input arrays. Now, let's see an example: Example 1: Python3 # import library import numpy as np # create a 1d-array a = np.array(("Geeks", "for", "geeks")) # create a 1d-array b = np.array(("my", "name", "sachin")) # convert 1d-arrays into # columns of 2d-array c = np.column_stack((a, b)) print(c) Output: [['Geeks' 'my'] ['for' 'name'] ['geeks' 'sachin']] Example 2: Python3 # import library import numpy as np # create 1d-array a = np.array((1,2,3,4)) # create 1d-array b = np.array((5,6,7,8)) # convert 1d-arrays into # columns of 2d-array c = np.column_stack((a, b)) print(c) Output: [[1 5] [2 6] [3 7] [4 8]] Comment More infoAdvertise with us Next Article How to convert 1-D arrays as columns into a 2-D array in Python? Y ysachin2314 Follow Improve Article Tags : Python Python-numpy Python numpy-arrayManipulation Practice Tags : python Similar Reads Convert 2D float array to 2D int array in NumPy Converting a 2D float array to a 2D integer array in NumPy is a straightforward process using the astype() method. This conversion can be useful in various data analysis and scientific computing tasks where integer data types are required or where memory efficiency is essential. In this article, we 8 min read How to convert 1D array of tuples to 2D Numpy array? In this article, we will discuss how to convert a 1D array of tuples into a numpy array. Example: Input: [(1,2,3),('Hi','Hello','Hey')] Output: [['1' '2' '3'] ['Hi' 'Hello' 'Hey']] #NDArray Method 1: Using Map The map is a function used to execute a function for each item in an Iterable i.e array. 2 min read Convert a 1D array to a 2D Numpy array Here we will learn how to convert 1D NumPy to 2D NumPy Using two methods. Numpy is a Python package that consists of multidimensional array objects and a collection of operations or routines to perform various operations on the array and processing of the array. Convert a 1D array to a 2D Numpy arr 3 min read How to convert a list and tuple into NumPy arrays? In this article, let's discuss how to convert a list and tuple into arrays using NumPy. NumPy provides various methods to do the same using Python. Example: Input: [3, 4, 5, 6]Output: [3 4 5 6]Explanation: Python list is converted into NumPy ArrayInput: ([8, 4, 6], [1, 2, 3])Output: [[8 4 6] [1 2 3] 2 min read How to convert an array of indices to one-hot encoded NumPy array A very popular technique used in machine learning to transform categorical data into binary values of 0 and 1 is called the one-hot encoding technique. There are various circumstances when you need to use a one-hot encoded NumPy array rather than an array of indices, thus we can convert it using the 3 min read How to Retrieve an Entire Row or Column of an Array in Python? Retrieving an entire row or column from an array in Python is a common operation, especially when working with matrices or tabular data. This can be done efficiently using different methods, especially with the help of NumPy. Letâs explore various ways to retrieve a full row or column from a 2D arra 3 min read Python | Flatten a 2d numpy array into 1d array Given a 2d numpy array, the task is to flatten a 2d numpy array into a 1d array. Below are a few methods to solve the task. Method #1 : Using np.flatten() Python3 # Python code to demonstrate # flattening a 2d numpy array # into 1d array import numpy as np ini_array1 = np.array([[1, 2, 3], [2, 4, 5] 2 min read How to convert NumPy array to dictionary in Python? The following article explains how to convert numpy array to dictionary in Python. Array in Numpy is a table of elements (usually numbers), all of the same type, indexed by a tuple of positive integers. In Numpy, number of dimensions of the array is called rank of the array. A tuple of integers givi 3 min read How to swap columns of a given NumPy array? In this article, let's discuss how to swap columns of a given NumPy array. Approach : Import NumPy moduleCreate a NumPy arraySwap the column with IndexPrint the Final array Example 1: Swapping the column of an array. Python3 # importing Module import numpy as np # creating array with shape(4,3) my_ 2 min read How to convert NumPy array to list ? This article will guide you through the process of convert a NumPy array to a list in Python, employing various methods and providing detailed examples for better understanding. Convert NumPy Array to List There are various ways to convert NumPy Array to List here we are discussing some generally us 4 min read Like