Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python NumPy insert Function Example Using insertion at different points

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

import numpy as np

#Working on 1D
arr = np.arange(6).reshape(2, 3)
print("1D arr : 
", arr)
print("Shape : ", arr.shape)

# value = 9
# index = 1
# Insertion before first index
a = np.insert(arr, (2, 4), 9)
print("
Insertion at two points : ", a)
print("Shape : ", a.shape)


# Working on 2D array
arr = np.arange(12).reshape(3, 4)
print("

2D arr : 
", arr)
print("Shape : ", arr.shape)
a = np.insert(arr, (0, 3), 66, axis = 1)
print("
Insertion at two points : 
", a)
print("Shape : ", a.shape)
Comment

PREVIOUS NEXT
Code Example
Python :: Python NumPy tile Function Example Working with 1D array 
Python :: Python NumPy vsplit Function Syntax 
Python :: Pandas DataFrame 2 
Python :: unsupported operand type python 
Python :: torch mean of tensor 
Python :: python __sub__ 
Python :: Python __truediv__ magic method 
Python :: object at being output python 
Python :: NumPy bitwise_and Example When inputs are arrays 
Python :: how to run string like normal code in python 
Python :: colorbar over two axes 
Python :: NumPy unpackbits Code Unpacked array along axis 1 
Python :: django filter empty onetoone exists 
Python :: flatten a list using numpy and itertools 
Python :: complete dates pandas per group by 
Python :: Remove Brackets from List Using join method 
Python :: login to sso.accounts.dowjones.com for wsj.com "python" 
Python :: How can I make portable python desktop application 
Python :: print(i) 
Python :: how to aggregate and add new column 
Python :: sqlite basic 
Python :: how to click button and download a file using robot frame work or selenium, it not contains link 
Python :: jupyter lab move tabs 
Python :: linkedin bot python 
Python :: ring Access List Items by String Index 
Python :: word cloud mape python 
Python :: python get message Exception 
Python :: 0 
Python :: python strip txt 
Python :: heatmap choos format for annotation 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =