What is that CustomerID called? is it index?
copy of the codes and output can be find here Sorry! Stack overflow is not allowing me to just copy and paste the picture here yet.
CodePudding user response:
It's called a hierarchical-index.
import pandas as pd
data = {
"foo": [1, 2, 3],
"spam": [4, 5, 6]
}
df = pd.DataFrame(data).set_index("foo")
uniques = len(df.index.unique("foo"))
print(uniques)
3