Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python NumPy stack Function Example with 2d array

# welcome to softhunt.net
# Python program explaining
# stack() function

import numpy as np

# input array
in_arr1 = np.array([[1, 3, 5], [-1, -3, -5]] )
print ("1st Input array : 
", in_arr1)

in_arr2 = np.array([[2, 4, 6], [-2, -4, -6]] )
print ("2nd Input array : 
", in_arr2)

# Stacking the two arrays along axis 0
out_arr1 = np.stack((in_arr1, in_arr2), axis = 0)
print ("Output stacked array along axis 0:
 ", out_arr1)

# Stacking the two arrays along axis 1
out_arr2 = np.stack((in_arr1, in_arr2), axis = 1)
print ("Output stacked array along axis 1:
 ", out_arr2)

# Stacking the two arrays along last axis
out_arr3 = np.stack((in_arr1, in_arr2), axis = -1)
print ("Output stacked array along last axis :
 ", out_arr3)
Comment

Python NumPy column_stack Function Example with 1d array

# welcome to softhunt.net
# Python program explaining
# column_stack() function

import numpy as np

# input array
in_arr1 = np.array((0, 1, 3,))
print ("1st Input array : 
", in_arr1)

in_arr2 = np.array((5, 7, 9))
print ("2nd Input array : 
", in_arr2)

# Stacking the two arrays
out_arr = np.column_stack((in_arr1, in_arr2))
print ("Output stacked array:
 ", out_arr)
Comment

Python NumPy column_stack Function Example with 2d array

# welcome to softhunt.net
# Python program explaining
# column_stack() function

import numpy as np

# input array
in_arr1 = np.array([[0, 1, 3], [-0, -1, -3]] )
print ("1st Input array : 
", in_arr1)

in_arr2 = np.array([[5, 7, 9], [-5, -7, -9]] )
print ("2nd Input array : 
", in_arr2)

# Stacking the two arrays
out_arr = np.column_stack((in_arr1, in_arr2))
print ("Output stacked array :
 ", out_arr)
Comment

Python NumPy row_stack Function Example with 2d array

# welcome to softhunt.net
# Python program explaining
# row_stack() function

import numpy as np

# input array
in_arr1 = np.array([[0, 1, 3], [-0, -1, -3]] )
print ("1st Input array : 
", in_arr1)

in_arr2 = np.array([[5, 7, 9], [-5, -7, -9]] )
print ("2nd Input array : 
", in_arr2)

# Stacking the two arrays
out_arr = np.row_stack((in_arr1, in_arr2))
print ("Output stacked array :
 ", out_arr)
Comment

PREVIOUS NEXT
Code Example
Python :: Python NumPy array_split Function Example 01 
Python :: First CGI program 
Python :: inverrt heatmap cmap 
Python :: watchlist flask app 
Python :: Python NumPy delete Function Example Deletion performed using Boolean Mask 
Python :: fpdf latin-1 
Python :: mid-point line drawing 
Python :: How to obtain a jpeg resolution in python 
Python :: Python how to use __truediv__ 
Python :: sorting a specific row python 
Python :: setstylesheet python 
Python :: ignopre rankwarning pyton 
Python :: NumPy left_shift Code When inputs and bit shift are an arrays 
Python :: ROS subscribes to image type video frames (Python) through topic Publishing 
Python :: after logout using back button is letting it use the flask application 
Python :: adjugate of 3x3 matrix in python 
Python :: Remove Brackets from List Using join method 
Python :: run server localhost for shar file 
Python :: How to convert an XML file to nice pandas dataframe 
Python :: wpapi 
Python :: python re return index of match 
Python :: tkinter screen clicked 
Python :: docstring python pycharm 
Python :: how to wait 5 seconds in python 
Python :: Frog Jump time complexity 
Python :: difflib get close matches 
Python :: python data statics 
Python :: void setup and void loop 
Python :: fibonacci sphere python 
Python :: python plot draw the goal line 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =