This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

vp.features.streaks

Consecutive active days (catalog/streaks.viv).

Part of the distribution vipyr; it runs from a checkout of the repository. Planned on PyPI as pip install vipyr.

Signature

vp.features.streaks(df=None, n=500)

Parameters

df : pandas.DataFrame, default None
The event table, rows in any order; None makes a synthetic one of n rows.
n : int, default 500
Rows of the synthetic table when df is None. Range: >= 1.

Returns

A frozen StreaksResult. Iterating it gives the fields below in order; it also has params, tests, log and check().

frame : pandas.DataFrame
The features, one row per input row, in the input's order and index: streak_days, longest_90d.
column of frame definition
streak_days consecutive active days ending on D, counting D (the row makes D active)
longest_90d longest run of consecutive active days inside D-89 .. D; a run that began before D-89 is cut at D-89

Raises

TypeError
An argument of the wrong type, or an unknown keyword.
vipyr.VivBuildError
An ImportError: no C compiler, or the program's C does not build.

Examples

import vipyr as vp
r = vp.features.streaks()                   # a synthetic table; pass df= for yours
print(r.frame.head())
assert r.check()
   streak_days  longest_90d
0            1            1
1            2            2
2            3            3
3            3            3
4            4            4

Each example ran as written when these pages were generated, and the output shown is what it printed.

Checked against

Reference
catalog.streaks_reference: a pandas groupby().apply() with a Python loop per row, equal bit for bit; vipyr.check_point_in_time: no feature reads a row after its own time

Source