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

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题