1>>> index = pd.Index([3, 1, 2, 3, 4, np.nan])
2>>> index.value_counts()
33.0 2
44.0 1
52.0 1
61.0 1
7dtype: int64
8
1df = df.value_counts().rename_axis('unique_values').reset_index(name='counts')
2print (df)
3 unique_values counts
40 2 3
51 1 2
6