statsmodels.tools.tools.add_constant(data, prepend=True, has_constant='skip')[source]

Adds a column of ones to an array

Parameters
dataarray-like

data is the column-ordered design matrix

prependbool

If true, the constant is in the first column. Else the constant is appended (last column).

Behavior if data already has a constant. The default will return data without adding another constant. If ‘raise’, will raise an error if a constant is present. Using ‘add’ will duplicate the constant, if one is present.