![]() ![]() While concatenating numpy arrays horizontally, you need to make sure that all the input arrays have the same number of rows. ![]() You can observe that the rows of the input arrays are combined to create the rows of the output array. In the above example, we have concatenated 2-D numpy arrays horizontally. After execution, the concatenate() function will return a numpy array as shown below. To concatenate the numpy arrays horizontally, you can pass a tuple of arrays as the first input argument and axis=1 as the second input argument to the concatenate() function. We can concatenate 2-D array horizontally and vertically using the concatenate() function. Concatenate 2-D arrays using the concatenate() function in Python Here, you can observe that we have tried to concatenate numpy arrays vertically using the concatenate() function that has led to the AxisError exception. Output: AxisError: axis 1 is out of bounds for array of dimension 1 You can observe this in the following example. ![]() Doing so will lead to numpy.AxisError exception with the message “numpy.AxisError: axis 1 is out of bounds for array of dimension 1”. You cannot concatenate 1-D numpy arrays using the concatenate() function vertically using the axis=1 parameter. Hence, all the elements of the input arrays are converted to elements of the output array. Here, we have concatenated two numpy arrays horizontally. You can concatenate 1-D numpy arrays using the concatenate() function by passing a tuple containing the numpy arrays as an input argument as shown below.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |