Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to input a string character into a numpy zeros imatrix n python

a = np.zeros((3,3),int)
a[[0,1,2],[2,0,1]] = [1,2,3]
a
array([[0, 0, 1],
       [2, 0, 0],
       [0, 3, 0]])

A = a.astype(str)
A
array([['0', '0', '1'],
       ['2', '0', '0'],
       ['0', '3', '0']],
      dtype='<U11')

A[[0,1,2],[0,1,2]] = 'X'
A 
array([['X', '0', '1'],
       ['2', 'X', '0'],
       ['0', '3', 'X']],
      dtype='<U11')
Comment

how to input a string character into a numpy zeros imatrix n python

a = np.zeros((3,3))
a 
array([[ 0.,  0.,  0.],
       [ 0.,  0.,  0.],
       [ 0.,  0.,  0.]])

a = np.zeros((3,3),int)
a
array([[0, 0, 0],
       [0, 0, 0],
       [0, 0, 0]])

a = np.zeros((3,3),bool)
a
array([[False, False, False],
       [False, False, False],
       [False, False, False]], dtype=bool)

a = np.zeros((3,3),str)
a 
array([['', '', ''],
       ['', '', ''],
       ['', '', '']],
      dtype='<U1')
Comment

PREVIOUS NEXT
Code Example
Python :: looping over folder to extract zip winrar python 
Python :: math plotlib 2 y axes 
Python :: check two list python not match 
Python :: draw a marker in basemap python 
Python :: transfer sound to hz with python 
Python :: latex maths to python parser 
Python :: datetime day deutsch python 
Python :: python scrape data from aspx page 
Python :: python how to change a point in a multidimensional list 
Python :: if len(i1.getbands()) == 1 
Python :: how to convert csv columns to text python 
Python :: hidden semi markov model python from scratch 
Python :: vvm 2020 exam date 
Python :: python Write code that asks users to enter the year they were born. Print out how many years old they will turn in 2019. 
Python :: jupyter notebook file not opening about::blank 
Python :: xml to sqlite 
Python :: fight club is the best movie ever 
Python :: Center labels matplotlib histogram 
Python :: numpy fancy indexing 
Python :: HTML automation not working on vscode with folder named templates on django 
Python :: input what is your name python 
Python :: using deque to make a list 
Python :: python string count complexity 
Python :: sample regression algorithm using pipeline with hyperparameter tuning 
Python :: kite order syntax 
Python :: fizzbuzz algorithm 
Python :: website screenshot python compress image 
Python :: real numbers python 
Python :: Fill NaN with the first valid value starting from the rightmost column, then extract first column 
Python :: python get favicon from url 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =