Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

np.hstack

# np.hstack concatenates arrays column-wise

a = np.array([1], [2], [3]) #read as a vector, i.e. a column
b = np.array([4], [5], [6]) #read as a vector, i.e. a column 
							#concatenated to the first one
c = np.hstack((a, b)))
print(c)
# output is
# [[1, 4],
#  [2, 5],
#  [3, 6]]
Comment

hstack in numpy

>>> a = np.array((1,2,3))
>>> b = np.array((2,3,4))
>>> np.hstack((a,b))
array([1, 2, 3, 2, 3, 4])
>>> a = np.array([[1],[2],[3]])
>>> b = np.array([[2],[3],[4]])
>>> np.hstack((a,b))
array([[1, 2],
       [2, 3],
       [3, 4]])
Comment

np.hstack in python

>>> a = np.array((1,2,3))
>>> b = np.array((2,3,4))
>>> np.hstack((a,b))
array([1, 2, 3, 2, 3, 4])
>>> a = np.array([[1],[2],[3]])
>>> b = np.array([[2],[3],[4]])
>>> np.hstack((a,b),columns=['hurala','panalal'])
array([[1, 2],
       [2, 3],
       [3, 4]])
Comment

PREVIOUS NEXT
Code Example
Python :: What happens when you use the built-in function any() on a list? 
Python :: last history of whatsapp message with python 
Python :: groupby year datetime pandas 
Python :: python print in one line 
Python :: How to install XGBoost package in python on Windows 
Python :: pandas map multiple columns 
Python :: python version installed in ubuntu 
Python :: look through dict 
Python :: pathlib path get directory of current file 
Python :: simple time in python 
Python :: python multithreading tutorials 
Python :: renaming multiple columns in pandas 
Python :: count number of zeros in a number python 
Python :: pandas new column from others 
Python :: python check folder 
Python :: with urllib.request.urlopen("https:// 
Python :: palindrome rearranging python 
Python :: dataframe column data type 
Python :: python set negative infinity 
Python :: python print version 
Python :: python selenium set attribute of element 
Python :: string to list separated by space python 
Python :: spacy ner 
Python :: index of max in tensor 
Python :: panda categorical data into numerica 
Python :: pandas str is in list 
Python :: read file from s3 python 
Python :: remove all instances from list python 
Python :: python cv2 get image shape 
Python :: python os.name mac 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =