Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python select random subset from numpy array

fruits = ['apple', 'banana', 'orange', 'grape']
subset_size = int(0.7 * len(fruits))
np.random.choice(fruits, subset_size, replace=False)
# array(['grape', 'banana'], dtype='<U6')
Comment

PREVIOUS NEXT
Code Example
Python :: rotatable list python 
Python :: drop columnd python 
Python :: english to japanese 
Python :: pandas fill blanks with zero 
Python :: get client ip flask 
Python :: pygame left click 
Python :: python how to get every name in folder 
Python :: tkinter button background color mac 
Python :: saving a pandas dataframe as a csv 
Python :: how to find largest number in array in python 
Python :: how to move columns in a dataframen in python 
Python :: install python package from git colab 
Python :: python working directory executed file 
Python :: migrate using other database django 
Python :: python regex remove digits from string 
Python :: python default input 
Python :: python loop through array backwards 
Python :: python save input to text file 
Python :: python opencv open camera 
Python :: python number guessing game 
Python :: get index of list item in loop 
Python :: get cpu count in python 
Python :: how to download file in python 
Python :: pandas to dict by row 
Python :: how to parse dicts in reqparse in flask 
Python :: python keyboard press 
Python :: split list in 3 part 
Python :: how to find location using latitude and longitude in python dataframe 
Python :: python overwrite print on same line 
Python :: convert two numpy array to pandas dataframe 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =