np.unique()
np.append(arr, value)
Finds the unique elements of an array.
- Input:
- arr : array
- The input array to find unique values for.
- Returns:
- The sorted unique values.
- Return Type:
- array
pets_species = pets.get('Species')
pets_species
- 0"dog"
- 1"cat"
- 2"cat"
- 3"dog"
- 4"dog"
- 5"hamster"
- 6"hamster"
- 7"cat"
species_array = np.array(pets_species)
array(['dog', 'cat', 'cat', 'dog', 'dog', 'hamster', 'hamster', 'cat'])
np.unique(species_array)
array(['cat', 'dog', 'hamster'])