pandas Series that contains the values from the species column. Then, we are calling the Series.nunique() function to get the total number of unique values in the Series.
On the other hand, pandas.unique(df[“species”]) gives us the unique values contained in the species column of the DataFrame.
The output of the above program will be:
sepal_length sepal_width petal_length petal_width species 0 5.1 3.5 1.4 0.2 setosa 1 4.9 3.0 1.4 0.2 setosa 2 4.7 3.2 1.3 0.2 setosa 3 4.6 3.1 1.5 0.2 setosa 4 5.0 3.6 1.4 0.2 setosa Total number of unique values: 3 The unique values: ['setosa' 'versicolor' 'virginica']








































0 Comments