How to convert 1-D arrays as columns into a 2-D array in Python? Last Updated : 13 Jan, 2021 Summarize Comments Improve Suggest changes Share 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 a list and tuple into NumPy arrays? 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 Dictionary into a NumPy Array In this article, we will learn how to convert a Python Dictionary into a numpy array which is more efficient for numerical operations and provides powerful tools for matrix and array manipulationsKey Steps to Convert a Dictionary to a NumPy ArrayUse dict.items(): This returns key-value pairs from th 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 Like