def count_places_by_user(staypoints):
    """
    Count how many places per user exist

    Parameters
    ----------
    staypoints : GeoDataFrame

    Returns
    -------
    places_by_user_count : dictionary
        Dictionary of type: {user_id: place_count}. It has the number of
        places per user.

    """
    all_users = staypoints["user_id"].unique()

    # delete invalid places if exist
    staypoints_a = staypoints.loc[staypoints['cluster_id'] != -1]

    # count places by user
    places_by_user_count = {}
    for user_id in all_users:
        unique_places = staypoints_a.loc[
            staypoints_a["user_id"] == user_id, 'cluster_id'].unique()

        places_by_user_count[user_id] = len(unique_places)

    return places_by_user_count