%23%20%2F%2F%2F%20script%0A%23%20requires-python%20%3D%20%22%3E%3D3.9%22%0A%23%20dependencies%20%3D%20%5B%0A%23%20%20%20%20%20%22detecta%22%2C%0A%23%20%20%20%20%20%22marimo%22%2C%0A%23%20%20%20%20%20%22matplotlib%22%2C%0A%23%20%20%20%20%20%22numpy%22%2C%0A%23%20%20%20%20%20%22pyversions%22%2C%0A%23%20%5D%0A%23%20%2F%2F%2F%0A%0Aimport%20marimo%0A%0A__generated_with%20%3D%20%220.25.2%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%20detect_seq.py%0A%0A%20%20%20%20A%20function%20from%20%5Bdetecta%5D(https%3A%2F%2Fpypi.org%2Fproject%2Fdetecta%2F)%20-%20Python%20module%20to%20detect%20events%20in%20data.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20The%20function%20%60detect_seq.py%60%20(%5Bsource%20code%5D(https%3A%2F%2Fgithub.com%2Fdemotu%2Fdetecta%2Fblob%2Fmaster%2Fdetecta%2Fdetect_seq.py))%20detects%20initial%20and%20final%20indices%20of%20sequential%20data%20identical%20to%20parameter%20%60value%60%20in%20%60x%60.%0A%20%20%20%20Use%20parameter%20%60min_seq%60%20to%20set%20the%20minimum%20number%20of%20sequential%20values%20to%20detect.%0A%0A%20%20%20%20The%20signature%20of%20%60detect_seq.py%60%20is%3A%0A%20%20%20%20%60%60%60python%0A%20%20%20%20idx%20%3D%20detect_seq(x%2C%20value%3Dnp.nan%2C%20index%3DFalse%2C%20min_seq%3D1%2C%20max_alert%3D0%2C%20show%3DFalse%2C%20ax%3DNone)%0A%20%20%20%20%60%60%60%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Installation%0A%0A%20%20%20%20%60%60%60bash%0A%20%20%20%20pip%20install%20%22detecta%5Bplot%5D%22%0A%20%20%20%20%60%60%60%0A%0A%20%20%20%20Or%0A%0A%20%20%20%20%60%60%60bash%0A%20%20%20%20conda%20install%20-c%20duartexyz%20detecta%0A%20%20%20%20%60%60%60%0A%0A%20%20%20%20To%20run%20this%20%5Bmarimo%5D(https%3A%2F%2Fmarimo.io)%20notebook%20in%20an%20isolated%20environment%20with%20all%20its%20dependencies%3A%0A%0A%20%20%20%20%60%60%60bash%0A%20%20%20%20uvx%20marimo%20edit%20--sandbox%20detect_seq.py%0A%20%20%20%20%60%60%60%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20import%20pyversions%0A%0A%20%20%20%20from%20detecta%20import%20detect_seq%0A%0A%20%20%20%20return%20detect_seq%2C%20mo%2C%20np%2C%20pyversions%0A%0A%0A%40app.cell%0Adef%20_(pyversions)%3A%0A%20%20%20%20_info%20%3D%20pyversions.versions()%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(detect_seq%2C%20mo)%3A%0A%20%20%20%20mo.doc(detect_seq)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Examples%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20x%20%3D%20%5B1%2C%200%2C%200%2C%200%2C%201%2C%201%2C%201%2C%200%2C%201%2C%200%2C%200%2C%200%5D%0A%20%20%20%20return%20(x%2C)%0A%0A%0A%40app.cell%0Adef%20_(detect_seq%2C%20x)%3A%0A%20%20%20%20detect_seq(x%2C%200)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(detect_seq%2C%20x)%3A%0A%20%20%20%20detect_seq(x%2C%200%2C%20index%3DTrue)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(detect_seq%2C%20x)%3A%0A%20%20%20%20detect_seq(x%2C%200%2C%20index%3DTrue%2C%20min_seq%3D2)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(detect_seq%2C%20x)%3A%0A%20%20%20%20detect_seq(x%2C%2010)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(detect_seq%2C%20x)%3A%0A%20%20%20%20detect_seq(x%2C%2010%2C%20index%3DTrue)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(detect_seq%2C%20x)%3A%0A%20%20%20%20detect_seq(x%2C%201%2C%20index%3DTrue%2C%20min_seq%3D2%2C%20show%3DTrue)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(detect_seq%2C%20x)%3A%0A%20%20%20%20detect_seq(x%2C%201%2C%20index%3DFalse%2C%20min_seq%3D1%2C%20show%3DTrue)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(detect_seq%2C%20x)%3A%0A%20%20%20%20detect_seq(x%2C%200%2C%20index%3DTrue%2C%20min_seq%3D2%2C%20show%3DTrue)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(detect_seq%2C%20x)%3A%0A%20%20%20%20detect_seq(x%2C%200%2C%20index%3DTrue%2C%20max_alert%3D2)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20Detect%20sequences%20of%20missing%20values%20(NaN's)%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(detect_seq%2C%20np)%3A%0A%20%20%20%20_x%20%3D%20%5B1%2C%202%2C%20np.nan%2C%20np.nan%2C%205%2C%204%2C%205%2C%20np.nan%2C%202%2C%201%2C%202%5D%0A%20%20%20%20detect_seq(_x%2C%20np.nan%2C%20index%3DTrue%2C%20max_alert%3D2%2C%20show%3DTrue)%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
e2811c074d5f630022d2d7edb6a7969b