def add_heading_change(points_df):
    """
    Returns a new dataframe with an added "heading_change" column.
    The heading change column has the heading change between this point and the
    two points preceding it. The first two rows have a speed of zero.
    """
    point_list = [ad.AttrDict(row) for row in points_df.to_dict('records')]
    zipped_points_list = zip(point_list, point_list[1:], point_list[2:])
    hcs = [pf.calHC(p1, p2, p3) for (p1, p2, p3) in zipped_points_list]
    hcs.insert(0, 0)
    hcs.insert(1, 0)
    with_hcs_df = pd.concat([points_df, pd.Series(hcs, name="heading_change")], axis=1)
    return with_hcs_df
Beispiel #2
0
def add_heading_change(points_df):
    """
    Returns a new dataframe with an added "heading_change" column.
    The heading change column has the heading change between this point and the
    two points preceding it. The first two rows have a speed of zero.
    """
    point_list = [ad.AttrDict(row) for row in points_df.to_dict('records')]
    zipped_points_list = list(zip(point_list, point_list[1:], point_list[2:]))
    hcs = [pf.calHC(p1, p2, p3) for (p1, p2, p3) in zipped_points_list]
    hcs.insert(0, 0)
    hcs.insert(1, 0)
    with_hcs_df = pd.concat(
        [points_df, pd.Series(hcs, name="heading_change")], axis=1)
    return with_hcs_df