def value_counts(self, dropna=True):
from numpy import bincount<EOL>from pandas import Series, CategoricalIndex<EOL>code, cat = self._codes, self.categories<EOL>ncat, mask = len(cat), <NUM_LIT:0> <= code<EOL>ix, clean = np.arange(ncat), mask.all()<EOL>if dropna or clean:<EOL><INDENT>obs = code if clean else code[mask]<EOL>count = bincount(obs, minlength=ncat or None)<EOL><DEDENT>else:<EOL><INDENT>count = bincount(np.where(mask, code, ncat))<EOL>ix = np.append(ix, -<NUM_LIT:1>)<EOL><DEDENT>ix = self._constructor(ix, dtype=self.dtype,<EOL>fastpath=True)<EOL>return Series(count, index=CategoricalIndex(ix), dtype='<STR_LIT>')<EOL>
Return a Series containing counts of each category.

Every category will have an entry, even those with a count of 0.

Parameters
----------
dropna : bool, default True
    Don't include counts of NaN.

Returns
-------
counts : Series

See Also
--------
Series.value_counts