@staticmethod
    def add_constant_(X):
        if X.ndim == 1:
            # treat vector-valued X differently
            X = np.insert(X[:, np.newaxis], 0, np.ones(len(X)), axis=1)
        else:
            X = np.insert(X, 0, np.ones(X.shape[0]), axis=1)

        return X
Add a constant to the linear model by prepending a column of ones to the feature array.
dataset/ETHPy150Open brandonckelly/bck_stats/bck_stats/dynamic_linear_model.py/DynamicLinearModel.add_constant_