# Buggy code
def predict(self, exog=None, transform=True, *args, **kwargs):
    """
    Call self.model.predict with self.params as the first argument.

    Parameters
    ----------
    exog : array-like, optional
        The values for which you want to predict.
    transform : bool, optional
        If the model was fit via a formula, do you want to pass
        exog through the formula. Default is True. E.g., if you fit
        a model y ~ log(x1) + log(x2), and transform is True, then
        you can pass a data structure that contains x1 and x2 in
        their original form. Otherwise, you'd need to log the data
        first.
    args, kwargs :
        Some models can take additional arguments or keywords, see the
        predict method of the model for the details.

    Returns
    -------
    prediction : ndarray, pandas.Series or pandas.DataFrame
        See self.model.predict

    """
    import pandas as pd

    exog_index = exog.index if _is_using_pandas(exog, None) else None

    if transform and hasattr(self.model, "formula") and exog is not None:
        from patsy import dmatrix

        exog = dmatrix(self.model.data.design_info.builder, exog)

    if exog is not None:
        exog = np.asarray(exog)
        if exog.ndim == 1 and (
            self.model.exog.ndim == 1 or self.model.exog.shape[1] == 1
        ):
            exog = exog[:, None]
        exog = np.atleast_2d(exog)  # needed in count model shape[1]

    predict_results = self.model.predict(self.params, exog, *args, **kwargs)

    if exog_index is not None and not hasattr(predict_results, "predicted_values"):
        if predict_results.ndim == 1:
            return pd.Series(predict_results, index=exog_index)
        else:
            return pd.DataFrame(predict_results, index=exog_index)

    else:
        return predict_results


# Traceback (ValueError)
Traceback (most recent call last):
File "E:\josef_new_notebook\scripts\bug_missing_formula.py", line 10, in <modu
le>
test3 = result3.predict(df3)     # Fails
File "E:\josef_new_notebook\git\statsmodels_py34_pr\statsmodels\base\model.py"
, line 767, in predict
return pd.Series(predict_results, index=exog_index)
File "C:\Users\josef\Downloads\WinPython-64bit-3.4.4.2\python-3.4.4.amd64\lib\
site-packages\pandas\core\series.py", line 228, in __init__
data = SingleBlockManager(data, index, fastpath=True)
File "C:\Users\josef\Downloads\WinPython-64bit-3.4.4.2\python-3.4.4.amd64\lib\
site-packages\pandas\core\internals.py", line 3752, in __init__
fastpath=True)
File "C:\Users\josef\Downloads\WinPython-64bit-3.4.4.2\python-3.4.4.amd64\lib\
site-packages\pandas\core\internals.py", line 2461, in make_block
return klass(values, ndim=ndim, fastpath=fastpath, placement=placement)
File "C:\Users\josef\Downloads\WinPython-64bit-3.4.4.2\python-3.4.4.amd64\lib\
site-packages\pandas\core\internals.py", line 84, in __init__
len(self.mgr_locs)))
ValueError: Wrong number of items passed 5, placement implies 6

# Fixed code
def predict(self, exog=None, transform=True, *args, **kwargs):
    """
    Call self.model.predict with self.params as the first argument.

    Parameters
    ----------
    exog : array-like, optional
        The values for which you want to predict.
    transform : bool, optional
        If the model was fit via a formula, do you want to pass
        exog through the formula. Default is True. E.g., if you fit
        a model y ~ log(x1) + log(x2), and transform is True, then
        you can pass a data structure that contains x1 and x2 in
        their original form. Otherwise, you'd need to log the data
        first.
    args, kwargs :
        Some models can take additional arguments or keywords, see the
        predict method of the model for the details.

    Returns
    -------
    prediction : ndarray, pandas.Series or pandas.DataFrame
        See self.model.predict

    """
    import pandas as pd

    exog_index = exog.index if _is_using_pandas(exog, None) else None

    if transform and hasattr(self.model, "formula") and exog is not None:
        from patsy import dmatrix

        exog = dmatrix(
            self.model.data.design_info.builder, exog, return_type="dataframe"
        )
        if len(exog) < len(exog_index):
            # missing values, rows have been dropped
            if exog_index is not None:
                exog = exog.reindex(exog_index)
            else:
                import warnings

                warnings.warn("nan rows have been dropped", ValueWarning)

    if exog is not None:
        exog = np.asarray(exog)
        if exog.ndim == 1 and (
            self.model.exog.ndim == 1 or self.model.exog.shape[1] == 1
        ):
            exog = exog[:, None]
        exog = np.atleast_2d(exog)  # needed in count model shape[1]

    predict_results = self.model.predict(self.params, exog, *args, **kwargs)

    if exog_index is not None and not hasattr(predict_results, "predicted_values"):
        if predict_results.ndim == 1:
            return pd.Series(predict_results, index=exog_index)
        else:
            return pd.DataFrame(predict_results, index=exog_index)

    else:
        return predict_results