pandas 求每列的唯一值个数

为计算数据框每一列的唯一值的个数我写了一个函数:

def unqiue_element(x):
    a=len(np.unqiue(x))
    return a
print "the number of unique items in each column",train.apply(unqiue_element)

出现错误
AttributeError: ("'module' object has no attribute 'unqiue'", u'occurred at index PatientId')
不知道怎么解决?我的写法有什么问题?

阅读 12.2k
1 个回答

unqiue。。。拼写有误?unique

推荐问题