我有两个分类特征“商品”和“行业类型”,对于“商品”中的每个分类值,我都必须获得“行业类型”中出现次数最多的分类值
Commodity Industry Type
-------------------------
Containers Logistics
Food Items Agro
Chemicals Pharma
Containers Chemical
Food Items Agro
Chemicals Soap
Containers Logistics
Food Items Agro
Chemicals Pharma
我尝试使用DataFrame.groupby('Commodity')。max()
预期:
Commodity Industry Type
--------------------------
Chemicals Pharma
Containers Logistics
Food Items Agro
实际:
Commodity Industry Type
--------------------------
Chemicals NaN
Containers Logistics
Food Items NaN