def track_length(tracks):
    """
    Calculate the number of points in each of a set of trajectories.

    args
    ----
        tracks      :   pandas.DataFrame

    returns
    -------
        same dataframe with "track_length" column 

    """
    if "track_length" in tracks.columns:
        tracks = tracks.drop("track_length", axis=1)
    tracks = tracks.join(
        tracks.groupby("trajectory").size().rename("track_length"),
        on="trajectory"
    )
    return tracks