Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

replace matrix values python

>>> A = np.array((1,7,3,8,4,9,1))
>>> np.where(A>4,1,A)
array([1, 1, 3, 1, 4, 1, 1])
Comment

replace matrix values python

>>> import numpy as np
   >>> M = np.arange(10)
   >>> M
   array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
   >>> M[(M > 2) & (M < 7)] = -1
   >>> M
   array([ 0,  1,  2, -1, -1, -1, -1,  7,  8,  9])
Comment

PREVIOUS NEXT
Code Example
Python :: how to assign a new value in a column in pandas dataframe 
Python :: python find file name 
Python :: Matplotlib rotated x tick labels 
Python :: create 8ball command in discord.py 
Python :: dataframe select columns based on list 
Python :: list of dataframe to dataframe 
Python :: python last item in list 
Python :: slicing in python listing 
Python :: pandas reset index 
Python :: dataframe python unique values rows 
Python :: get turtle pos 
Python :: pie plot in python 
Python :: how to print keys and values of dictionary together in python? 
Python :: python generate list 
Python :: jupyter dark theme vampire 
Python :: python string contains 
Python :: matplotlib different number of subplots 
Python :: python combine two lists into matrix 
Python :: python variable declare 
Python :: add key if not exists python 
Python :: isalnum python 
Python :: flatten list python 
Python :: python if string contains substring 
Python :: split pandas dataframe in two 
Python :: python str contains word 
Python :: python autocorrelation plot 
Python :: if string is in array python 
Python :: Find column whose name contains a specific string 
Python :: screen.onkey python 
Python :: python get the intersection of two lists 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =