在Python的DataFrame列中获取值的频率

问题描述

我得到的一个家庭作业问题的一部分:我需要使用Pandas从DataFrame的列中获取唯一值的频率。但是,我必须使用crosstab()函数

这是DataFrame的一部分

enter image description here

我想在'E'列中获取'color'的频率(百分比)。

结果如下所示:

enter image description here

这就是我到目前为止所拥有的:

enter image description here

我在做什么错?我怎么能一样呢?

解决方法

pd.crosstab(“”,dataframe [],normalize = True)