unique

unique,第1张

unique()函数

unique()函数可输出列表,元组和series中的不同元素。


且只能输出dataframe的某一列series中的不同元素,不能同时输出。


返回的都是一个ndarry,但不能输出ndarry中的不同元素,即对ndarry无效


 A = [1, 2, 2, 5,3, 4, 3]
a = np.unique(A)
B= (1, 2, 2,5, 3, 4, 3)
b= np.unique(B)
C= ['fgfh','asd','fgfh','asdfds','wrh']
c= np.unique(C)
d = df['列名'].unique()
print(a)
print(b)
print(c)
print(date_received)
# [1 2 3 4 5]
# [1 2 3 4 5]
# ['asd' 'asdfds' 'fgfh' 'wrh']
# ['20160113' '20160108' '20160115' '20160513' '20160208'
# '20160310' '20160307' '20160221' '20160226' '20160309']

参考: https://blog.csdn.net/yangyuwen_yang/article/details/79193770

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/585748.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-12
下一篇 2022-04-12

发表评论

登录后才能评论

评论列表(0条)

保存