lisa.datautils.df_squash#

lisa.datautils.df_squash(df, start, end, column='delta')[source]#

Slice a dataframe of deltas in [start:end] and ensure we have an event at exactly those boundaries.

The input dataframe is expected to have a “column” which reports the time delta between consecutive rows, as for example dataframes generated by df_add_delta().

The returned dataframe is granted to have an initial and final event at the specified “start” (“end”) index values, which values are the same of the last event before (first event after) the specified “start” (“end”) time.

Examples:

Slice a dataframe to [start:end], and work on the time data so that it makes sense within the interval.

Examples to make it clearer:

df is:
Time len state
15    1   1
16    1   0
17    1   1
18    1   0
-------------

df_squash(df, 16.5, 17.5) =>

Time len state
16.5  .5   0
17    .5   1

df_squash(df, 16.2, 16.8) =>

Time len state
16.2  .6   0
Returns:

a new df that fits the above description