Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python NumPy append Function Example Working with axis

# welcome to softhunt.net
# Python Program illustrating
# numpy.append()

import numpy as np

#Working on 1D
arr1 = np.arange(8).reshape(2, 4)
print("2D arr1 : 
", arr1)
print("Shape : ", arr1.shape)


arr2 = np.arange(8, 16).reshape(2, 4)
print("
2D arr2 : 
", arr2)
print("Shape : ", arr2.shape)


# appending the arrays
arr3 = np.append(arr1, arr2)
print("
Appended arr3 by flattened : ", arr3)

# appending the arrays with axis = 0
arr3 = np.append(arr1, arr2, axis = 0)
print("
Appended arr3 with axis 0 : 
", arr3)

# appending the arrays with axis = 1
arr3 = np.append(arr1, arr2, axis = 1)
print("
Appended arr3 with axis 1 : 
", arr3)
Comment

PREVIOUS NEXT
Code Example
Python :: Python NumPy repeat Function Example Working with 1D array 
Python :: Python NumPy dsplit Function Syntax 
Python :: fpdf latin-1 
Python :: python increase a value every n rows 
Python :: python how to loop through array 
Python :: pandas dt.weekday to string 
Python :: Python how to use __div__ 
Python :: create different size matplotlib 
Python :: NumPy rot90 Example Rotating four times 
Python :: else clause in for loop python 
Python :: import date formater 
Python :: NumPy unpackbits Code Unpacked array along default axis 
Python :: miniforge cv2 vscode 
Python :: python override inherited method data model constructor 
Python :: adjugate of 3x3 matrix in python 
Python :: Fatal Python error: Cannot recover from stack overflow. 
Python :: list python !g 
Python :: python tkinter.ttk combobox down event on mouseclick 
Python :: send by email in odoo 14 
Python :: pandas groupby min get index 
Python :: Dynamic INSERT to SQLite 
Python :: AJAX/FLASK/JS: How to POST existing array into endpoint 
Python :: pandas combine bool columns 
Python :: python go back one using abspath 
Python :: ring Copy Lists 
Python :: for loop the string from reverse order and skipping last element in string python 
Python :: remove kernel 
Python :: matplotlib doesnt show suptitle 
Python :: sympy.diff 
Python :: remove inner list from outer list python 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =