def count(data, column, mapping=None, probability=False, return_param=False):
    """ Performs frequency encoding.

        Categories are replaced by their number of occurence.
        Soon: possibility of probability instead of count (normalization)

        :param df: Data
        :param column: Column to encode
        :param mapping: Dictionary {category : value}
        :param probability: If True, return probability instead of frequency
        :param return_param: If True, the mapping is returned
        :return: Encoded data
        :rtype: pd.DataFrame
    """
    categories = data[column].unique()
    if mapping is None:
        mapping = dict()
        for e in data[column]:
            if e in mapping:
                mapping[e] += 1
            else:
                mapping[e] = 1
    else:
        for category in categories:
            if category not in mapping:
                mapping[category] = 0
    if probability:
        factor = 1.0 / sum(mapping.values())
        for k in mapping:
            mapping[k] = float(format(mapping[k] * factor, '.3f'))
    data[column] = data[column].map(mapping)
    if return_param:
        return data, mapping
    return data
