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