diff --git a/doc/source/r_interface.rst b/doc/source/r_interface.rst index 98fc4edfd5816..826d9e980538e 100644 --- a/doc/source/r_interface.rst +++ b/doc/source/r_interface.rst @@ -13,11 +13,9 @@ rpy2 / R interface ****************** -.. note:: - - This is all highly experimental. I would like to get more people involved - with building a nice RPy2 interface for pandas +.. warning:: + In v0.16.0, the ``pandas.rpy`` interface has been **deprecated and will be removed in a future version**. Similar functionaility can be accessed thru the `rpy2 `_ project. If your computer has R and rpy2 (> 2.2) installed (which will be left to the reader), you will be able to leverage the below functionality. On Windows, diff --git a/doc/source/whatsnew/v0.13.0.txt b/doc/source/whatsnew/v0.13.0.txt index 78239eef1b98f..2e10ae4ea668d 100644 --- a/doc/source/whatsnew/v0.13.0.txt +++ b/doc/source/whatsnew/v0.13.0.txt @@ -617,6 +617,7 @@ Enhancements .. code-block:: python + # note that pandas.rpy was deprecated in v0.16.0 import pandas.rpy.common as com com.load_data('Titanic') diff --git a/doc/source/whatsnew/v0.16.0.txt b/doc/source/whatsnew/v0.16.0.txt index c631faf09747f..2d85584168f48 100644 --- a/doc/source/whatsnew/v0.16.0.txt +++ b/doc/source/whatsnew/v0.16.0.txt @@ -387,6 +387,10 @@ Deprecations - The ``pandas.sandbox.qtpandas`` interface is deprecated and will be removed in a future version. We refer users to the external package `pandas-qt `_. (:issue:`9615`) +- The ``pandas.rpy`` interface is deprecated and will be removed in a future version. + Similar functionaility can be accessed thru the `rpy2 `_ project (:issue:`9602`) + + .. _whatsnew_0160.prior_deprecations: Removal of prior version deprecations/changes diff --git a/pandas/rpy/__init__.py b/pandas/rpy/__init__.py index d5cf8a420b727..899b684ecbff9 100644 --- a/pandas/rpy/__init__.py +++ b/pandas/rpy/__init__.py @@ -1,3 +1,12 @@ + +# GH9602 +# deprecate rpy to instead directly use rpy2 + +import warnings +warnings.warn("The pandas.rpy module is deprecated and will be " + "removed in a future version. We refer to external packages " + "like rpy2, found here: http://rpy.sourceforge.net", FutureWarning) + try: from .common import importr, r, load_data except ImportError: diff --git a/pandas/stats/tests/test_var.py b/pandas/stats/tests/test_var.py index ab5709d013fa9..c6eca4041a61b 100644 --- a/pandas/stats/tests/test_var.py +++ b/pandas/stats/tests/test_var.py @@ -21,16 +21,6 @@ reload(_pvar) from pandas.stats.var import VAR -try: - import rpy2.robjects as robj - from rpy2.robjects import r - from rpy2.robjects.packages import importr - import pandas.rpy.common as rpy - vars = importr('vars') - urca = importr('urca') -except ImportError: - pass - DECIMAL_6 = 6 DECIMAL_5 = 5 DECIMAL_4 = 4 @@ -99,97 +89,5 @@ def __init__(self): self.res2 = results_var.MacrodataResults() -class RVAR(object): - """ - Estimates VAR model using R vars package and rpy - """ - - def __init__(self, data, p=1, type='both'): - self.rdata = data - self.p = p - self.type = type - - self.pydata = rpy.convert_robj(data) - self._estimate = None - self.estimate() - - @property - def aic(self): - pass - - @property - def bic(self): - pass - - @property - def beta(self): - return rpy.convert_robj(r.coef(self._estimate)) - - def summary(self, equation=None): - print(r.summary(self._estimate, equation=equation)) - - def output(self): - print(self._estimate) - - def estimate(self): - self._estimate = r.VAR(self.rdata, p=self.p, type=self.type) - - def plot(self, names=None): - r.plot(model._estimate, names=names) - - def serial_test(self, lags_pt=16, type='PT.asymptotic'): - f = r['serial.test'] - - test = f(self._estimate, **{'lags.pt': lags_pt, - 'type': type}) - - return test - - def data_summary(self): - print(r.summary(self.rdata)) - - -class TestVAR(TestCase): - - def setUp(self): - try: - import rpy2 - except ImportError: - raise nose.SkipTest("No rpy2") - - self.rdata = rpy.load_data('Canada', package='vars', convert=False) - self.data = rpy.load_data('Canada', package='vars', convert=True) - - self.res = VAR(self.data) - self.ref = RVAR(self.rdata) - - def test_foo(self): - pass - if __name__ == '__main__': - # canada = rpy.load_data('Canada', package='vars', convert=False) - - # model = RVAR(canada, p=1) - - # summary(Canada) - - # plot(Canada, nc=2, xlab="")ppp - - # adf1 <- summary(ur.df(Canada[, "prod"], type = "trend", lags = 2)) - # adf1 - - # adf2 <- summary(ur.df(diff(Canada[, "prod"]), type = "drift", lags = 1)) - # adf2 - - # VARselect(Canada, lag.max = 8, type = "both") - - # Canada <- Canada[, c("prod", "e", "U", "rw")] - - # p1ct <- VAR(Canada, p = 1, type = "both") - # p1ct - - # coefs <- coef(p1ct) - # class(coefs) - - # run_module_suite() unittest.main() diff --git a/pandas/util/print_versions.py b/pandas/util/print_versions.py index d3dbeef1af4d2..c1804c34ce3d2 100644 --- a/pandas/util/print_versions.py +++ b/pandas/util/print_versions.py @@ -83,7 +83,6 @@ def show_versions(as_json=False): ("html5lib", lambda mod: mod.__version__), ("httplib2", lambda mod: mod.__version__), ("apiclient", lambda mod: mod.__version__), - ("rpy2", lambda mod: mod.__version__), ("sqlalchemy", lambda mod: mod.__version__), ("pymysql", lambda mod: mod.__version__), ("psycopg2", lambda mod: mod.__version__),