How to I factorize a list of tuples?

后端 未结 6 2009
春和景丽
春和景丽 2020-12-06 10:43

definition
factorize: Map each unique object into a unique integer. Typically, the range of integers mapped to is from zero to the n - 1 where n is

6条回答
  •  醉梦人生
    2020-12-06 10:59

    Initialize your list of tuples as a Series, then call factorize:

    pd.Series(tups).factorize()[0]
    
    [0 1 2 3 4 1 2]
    

提交回复
热议问题