Repository: pandas-dev/pandas

Issue:
DEPR/DOC: rpy deprecation
so we should put up a deprecation notice on `rpy`imports that in the future the user should use  `rpy2` directly rather than the less-supported  `pandas.rpy` converters that we can take action say in 0.17.0

discussed extensivley in #7385 

xref #7385, #9187 #7309, #8255 
- [x] Update the docs with some example of how to port your pandas examples to the `rpy2` API -> done with #10075
- [ ] Go over the functionality in pandas and check if some things should be ported to `rpy2` (what still works better in pandas?)
  - [ ] Handling of NaN values (comment below: https://github.com/pydata/pandas/issues/9602#issuecomment-94716332)
  - [ ] index is not preserved in `ri2py` -> this should be handled in https://bitbucket.org/rpy2/rpy2/issues/285
- [ ] The closed PRs -> push them to `rpy2`?



Discussion:

Resolving patch:
diff --git a/pandas/rpy/__init__.py b/pandas/rpy/__init__.py
--- 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/util/print_versions.py b/pandas/util/print_versions.py
--- 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__),


Test patch:
diff --git a/pandas/stats/tests/test_var.py b/pandas/stats/tests/test_var.py
--- 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()