我有一个看起来像这样的df
region Business Unit Aladdin Legal_Entity prime_broker_id sedol6 tempBucket
0 EMEA SAE EDEA_AG BARCAP 010486 GC
1 EMEA SAE EDEA_AG BARCAP 010486 GC
2 EMEA SAE EDEA_AG BARCAP 010486 GC
3 EMEA SAE EDEA_AG BARCAP 017714 NotGC
4 EMEA SAE EDEA_AG BARCAP 017714 NotGC
5 EMEA SAE EDEA_AG BARCAP 017714 NotGC
6 EMEA SAE EDEA_AG BARCAP 017714 NotGC
7 EMEA SAE EDEA_AG BARCAP 017714 NotGC
8 EMEA SAE EDEA_AG BARCAP 017714 NotGC
当我尝试查找唯一值时,我会报错
C, ia,ic=np.unique(df, return_index=True, return_inverse=True, axis=0)
TypeError: The axis argument to unique is not supported for dtype object
我试图将数据框转换为数组
C, ia,ic=np.unique(df.values, return_index=True, return_inverse=True, axis=0)
但是我遇到同样的错误:
TypeError: The axis argument to unique is not supported for dtype object
我也尝试过:
C, ia,ic=np.unique(df.to_numpy(), return_index=True, return_inverse=True, axis=0)
但是它也不起作用。我得到一个错误
AttributeError: 'DataFrame' object has no attribute 'to_numpy'
可以帮忙吗?
谢谢