Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

numpy replace

import numpy as np
array1 = np.array([2, 2, 2, 0, 2, 0, 2])
print(np.where(array1==0, 1, array1))
# OUTPUT = [2 2 2 1 2 1 2]
Comment

PREVIOUS NEXT
Code Example
Python :: how to get rid of all null values in array python 
Python :: Geopandas to SHP file 
Python :: tkinter remove frame 
Python :: knn classifier python example 
Python :: python change cwd to script directory 
Python :: python read live radio 
Python :: playsound module in python 
Python :: python dataframe get numeric columns 
Python :: how to run a function in interval in python 
Python :: researchpy correlation 
Python :: spacy remove stop words 
Python :: tkinter entry read only 
Python :: random word py 
Python :: decrypt python code 
Python :: pandas replace na with 0 
Python :: dataframe to dictionary with one column as key 
Python :: open python choose encoding 
Python :: time counter in python 
Python :: youtube-dl python download to specific folder 
Python :: virtual environment flask 
Python :: python set symmetric difference 
Python :: python thread with parameters 
Python :: set axis plt python 
Python :: default argument in flask route 
Python :: how to test wifi speed py 
Python :: pandas change column name from a dictionary 
Python :: python zfill 
Python :: list loop python 
Python :: sort tuple list python 
Python :: remove outliers numpy array 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =