This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM jupyter/datascience-notebook | |
USER root | |
RUN apt-get update && apt-get install -yq graphviz | |
USER $NB_USER | |
RUN pip install lingam graphviz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def lag(x, n=0): | |
observed = np.isnan(x) == False | |
observed[0] = True | |
offsets = np.flatnonzero(observed) | |
return offsets[np.maximum(np.cumsum(observed) - 1 - n, 0)] | |
OlderNewer