diff --git a/pandas/stats/ols.py b/pandas/stats/ols.py index 9d22068c1612f..83fb387254eda 100644 --- a/pandas/stats/ols.py +++ b/pandas/stats/ols.py @@ -445,12 +445,12 @@ def predict(self, beta=None, x=None, fill_value=None, orig_x = x else: orig_x = x + if isinstance(x, Series): + x = DataFrame({'x': x}) if fill_value is None and fill_method is None: x = x.dropna(how='any') else: x = x.fillna(value=fill_value, method=fill_method, axis=axis) - if isinstance(x, Series): - x = DataFrame({'x': x}) if self._intercept: x['intercept'] = 1. diff --git a/pandas/stats/tests/test_ols.py b/pandas/stats/tests/test_ols.py index df2f545c90b92..e487eb3bad5b8 100644 --- a/pandas/stats/tests/test_ols.py +++ b/pandas/stats/tests/test_ols.py @@ -378,6 +378,9 @@ def test_series_rhs(self): model = ols(y=y, x=x) expected = ols(y=y, x={'x': x}) assert_series_equal(model.beta, expected.beta) + + # Test predict using a series + assert_series_equal(model.y_predict, model.predict(x=x)) def test_various_attributes(self): # just make sure everything "works". test correctness elsewhere