import numpy as np
arr = np.array([2, 4, 2, 5, 3, 5, 1, 1, 0, 5])
unique_arr = np.unique(arr)
print(unique_arr)
# output: [0 1 2 3 4 5]
import pandas as pd
# create a sample pandas
Seriesdata = pd.Series([1, 2, 2, 3, 3, 3, None])
# compute the number of unique values in the Series
num_unique = data.nunique()
print(num_unique)
# output: 3
网友评论