统计NumPy数组中每种元素的占比 1、效果 2、解决方案 使用NumPy的unique()函数结合计数功能。 3、示例代码 import numpy as np def count_element_proportions(arr): """ 统计NumPy数组中每种元素的占比 参数: arr (np.ndarray): 输入的NumPy数组 返回: