Get the unique values in list
for p in m : NEW_LINE INDENT vals . append ( p ) NEW_LINE DEDENT res = sys . maxsize NEW_LINE for i in range ( 1 , len ( vals ) ) : NEW_LINE INDENT vec = [ m [ vals [ i ] ] ] NEW_LINE DEDENT