Closest equivalent of a factor variable in Python Pandas

前端 未结 4 376
我在风中等你
我在风中等你 2020-12-13 18:33

What is the closest equivalent to an R Factor variable in Python pandas?

4条回答
  •  無奈伤痛
    2020-12-13 19:04

    C # array containing category data
    V # array containing numerical data
    
    H = np.unique(C)
    mydict = {}
    for h in H:
        mydict[h] = V[C==h]
    
    
    boxplot(mydict.values(), labels=mydict.keys())
    

提交回复
热议问题