Horje
numpy random for string Code Example
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')
numpy random for string
>>> aa_milne_arr = ['pooh', 'rabbit', 'piglet', 'Christopher']
>>> np.random.choice(aa_milne_arr, 5, p=[0.5, 0.1, 0.1, 0.3])
array(['pooh', 'pooh', 'pooh', 'Christopher', 'piglet'],
      dtype='|S11')



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')




Python

Related
Identify Null and NAN python Code Example Identify Null and NAN python Code Example
bash install wheel Code Example bash install wheel Code Example
How to make a function repeat itself a specifc amount of times python Code Example How to make a function repeat itself a specifc amount of times python Code Example
title() in python Code Example title() in python Code Example
run julia in p;ython Code Example run julia in p;ython Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
6