Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

np.random.choice replace

#You can use it when you want sample some elements from a list, 
#and meanwhile you want the elements no repeat,
#then you can set the "replace=False".

eg:
from numpy import random as rd
ary = list(range(10))
rd.choice(ary, size=8, replace=False)
[out] : array([0, 5, 9, 8, 2, 1, 6, 3])  # no repeated elements
rd.choice(ary, size=8, replace=True)
[Out]: array([4, 9, 8, 5, 4, 1, 1, 9])  # elements may be repeated
Comment

PREVIOUS NEXT
Code Example
Python :: python inspect class 
Python :: how to get user input in python 
Python :: syntax error in python 
Python :: remove nan from list 
Python :: python code for finding prime numbers 
Python :: signup view django 
Python :: read bin file python 
Python :: add rectangle to image python 
Python :: import one hot encoder 
Python :: whatsapp bot python code 
Python :: round to 3 significant figures python 
Python :: padding figures in pyplot 
Python :: if with && in python 
Python :: random forest 
Python :: python global variables 
Python :: set password django 
Python :: python dunder methods 
Python :: np.vstack python 
Python :: python run system commands 
Python :: hash password python 
Python :: math in function 
Python :: pip for python 
Python :: find key by value python 
Python :: re python 
Python :: how to add number to string in python 
Python :: tkinter filedialog filename 
Python :: return programming 
Python :: open chrome console in selenium 
Python :: sns histplot change legend labels 
Python :: parse receipt python 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =