Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python NumPy stack Function Example with 1d array

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

import numpy as np

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

in_arr2 = np.array([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)
Comment

Python NumPy vstack Function Example with 1d array

# Python program explaining
# vstack() function

import numpy as geek

# input array
in_arr1 = geek.array([ 1, 2, 3] )
print ("1st Input array : 
", in_arr1)

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

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

Python NumPy hstack Function Example with 1d array

# welcome to softhunt.net
# Python program explaining
# hstack() 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 horizontally
out_arr = np.hstack((in_arr1, in_arr2))
print ("Output horizontally stacked array:
 ", out_arr)
Comment

PREVIOUS NEXT
Code Example
Python :: Python NumPy dstack Function Example 02 
Python :: Python NumPy row_stack Function Example with 2d array 
Python :: First CGI program 
Python :: objects list 
Python :: configure socketio static file python 
Python :: Python NumPy dsplit Function Syntax 
Python :: how to add to an exsiting value of an index in a list 
Python :: if statment with logical or operator for multiple varaibles 
Python :: Python how to use __sub__ 
Python :: create different size matplotlib 
Python :: Program to get number of consecutive repeated substring 
Python :: get forex exchange rates in python 
Python :: NumPy bitwise_xor Code When inputs are Boolean 
Python :: how to do something daily python 
Python :: change admin password djano 
Python :: pandas cleaning dataframe regex 
Python :: how to avoind DeprecationWarning in python 
Python :: raspberry pi set python 3 as default 
Python :: How to use a <ComboboxSelected virtual event with tkinter 
Python :: if is 
Python :: how to make a yes or no question in python 
Python :: find sum of all elements in a matrix by python 
Python :: How to correctly call url_for and specify path parameters 
Python :: typing effect python 
Python :: python for loop skip iteration if condition not met jinja 
Python :: ring raise an exception 
Python :: ring Trace library usage to pass an error 
Python :: matplotlib plot dpi - change format to retina instead of svg 
Python :: convert python code to c++ online 
Python :: obtenir coordonnees souris python 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =