def value_occurence(s):
    """Count the number of times each value occurs.

    This function returns the counts for each row, in contrast with
    `pandas.value_counts <http://pandas.pydata.org/pandas-
    docs/stable/generated/pandas.Series.value_counts.html>`_.

    Returns
    -------
    pandas.Series
        A Series with value counts.

    """

    # https://github.com/pydata/pandas/issues/3729
    value_count = s.fillna('NAN')

    return value_count.groupby(by=value_count).transform('count')