Skip to content

Commit 89f9eb6

Browse files
committed
Merge pull request #9612 from jreback/rpy
DEPR: deprecate pandas.rpy (GH9602)
2 parents 9bb1353 + 350b39b commit 89f9eb6

File tree

6 files changed

+16
-107
lines changed

6 files changed

+16
-107
lines changed

doc/source/r_interface.rst

+2-4
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
rpy2 / R interface
1414
******************
1515

16-
.. note::
17-
18-
This is all highly experimental. I would like to get more people involved
19-
with building a nice RPy2 interface for pandas
16+
.. warning::
2017

18+
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 <http://rpy.sourceforge.net/>`_ project.
2119

2220
If your computer has R and rpy2 (> 2.2) installed (which will be left to the
2321
reader), you will be able to leverage the below functionality. On Windows,

doc/source/whatsnew/v0.13.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ Enhancements
617617

618618
.. code-block:: python
619619

620+
# note that pandas.rpy was deprecated in v0.16.0
620621
import pandas.rpy.common as com
621622
com.load_data('Titanic')
622623

doc/source/whatsnew/v0.16.0.txt

+4
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,10 @@ Deprecations
387387
- The ``pandas.sandbox.qtpandas`` interface is deprecated and will be removed in a future version.
388388
We refer users to the external package `pandas-qt <https://github.com/datalyze-solutions/pandas-qt>`_. (:issue:`9615`)
389389

390+
- The ``pandas.rpy`` interface is deprecated and will be removed in a future version.
391+
Similar functionaility can be accessed thru the `rpy2 <http://rpy.sourceforge.net/>`_ project (:issue:`9602`)
392+
393+
390394
.. _whatsnew_0160.prior_deprecations:
391395

392396
Removal of prior version deprecations/changes

pandas/rpy/__init__.py

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2+
# GH9602
3+
# deprecate rpy to instead directly use rpy2
4+
5+
import warnings
6+
warnings.warn("The pandas.rpy module is deprecated and will be "
7+
"removed in a future version. We refer to external packages "
8+
"like rpy2, found here: http://rpy.sourceforge.net", FutureWarning)
9+
110
try:
211
from .common import importr, r, load_data
312
except ImportError:

pandas/stats/tests/test_var.py

-102
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@
2121
reload(_pvar)
2222
from pandas.stats.var import VAR
2323

24-
try:
25-
import rpy2.robjects as robj
26-
from rpy2.robjects import r
27-
from rpy2.robjects.packages import importr
28-
import pandas.rpy.common as rpy
29-
vars = importr('vars')
30-
urca = importr('urca')
31-
except ImportError:
32-
pass
33-
3424
DECIMAL_6 = 6
3525
DECIMAL_5 = 5
3626
DECIMAL_4 = 4
@@ -99,97 +89,5 @@ def __init__(self):
9989
self.res2 = results_var.MacrodataResults()
10090

10191

102-
class RVAR(object):
103-
"""
104-
Estimates VAR model using R vars package and rpy
105-
"""
106-
107-
def __init__(self, data, p=1, type='both'):
108-
self.rdata = data
109-
self.p = p
110-
self.type = type
111-
112-
self.pydata = rpy.convert_robj(data)
113-
self._estimate = None
114-
self.estimate()
115-
116-
@property
117-
def aic(self):
118-
pass
119-
120-
@property
121-
def bic(self):
122-
pass
123-
124-
@property
125-
def beta(self):
126-
return rpy.convert_robj(r.coef(self._estimate))
127-
128-
def summary(self, equation=None):
129-
print(r.summary(self._estimate, equation=equation))
130-
131-
def output(self):
132-
print(self._estimate)
133-
134-
def estimate(self):
135-
self._estimate = r.VAR(self.rdata, p=self.p, type=self.type)
136-
137-
def plot(self, names=None):
138-
r.plot(model._estimate, names=names)
139-
140-
def serial_test(self, lags_pt=16, type='PT.asymptotic'):
141-
f = r['serial.test']
142-
143-
test = f(self._estimate, **{'lags.pt': lags_pt,
144-
'type': type})
145-
146-
return test
147-
148-
def data_summary(self):
149-
print(r.summary(self.rdata))
150-
151-
152-
class TestVAR(TestCase):
153-
154-
def setUp(self):
155-
try:
156-
import rpy2
157-
except ImportError:
158-
raise nose.SkipTest("No rpy2")
159-
160-
self.rdata = rpy.load_data('Canada', package='vars', convert=False)
161-
self.data = rpy.load_data('Canada', package='vars', convert=True)
162-
163-
self.res = VAR(self.data)
164-
self.ref = RVAR(self.rdata)
165-
166-
def test_foo(self):
167-
pass
168-
16992
if __name__ == '__main__':
170-
# canada = rpy.load_data('Canada', package='vars', convert=False)
171-
172-
# model = RVAR(canada, p=1)
173-
174-
# summary(Canada)
175-
176-
# plot(Canada, nc=2, xlab="")ppp
177-
178-
# adf1 <- summary(ur.df(Canada[, "prod"], type = "trend", lags = 2))
179-
# adf1
180-
181-
# adf2 <- summary(ur.df(diff(Canada[, "prod"]), type = "drift", lags = 1))
182-
# adf2
183-
184-
# VARselect(Canada, lag.max = 8, type = "both")
185-
186-
# Canada <- Canada[, c("prod", "e", "U", "rw")]
187-
188-
# p1ct <- VAR(Canada, p = 1, type = "both")
189-
# p1ct
190-
191-
# coefs <- coef(p1ct)
192-
# class(coefs)
193-
194-
# run_module_suite()
19593
unittest.main()

pandas/util/print_versions.py

-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ def show_versions(as_json=False):
8383
("html5lib", lambda mod: mod.__version__),
8484
("httplib2", lambda mod: mod.__version__),
8585
("apiclient", lambda mod: mod.__version__),
86-
("rpy2", lambda mod: mod.__version__),
8786
("sqlalchemy", lambda mod: mod.__version__),
8887
("pymysql", lambda mod: mod.__version__),
8988
("psycopg2", lambda mod: mod.__version__),

0 commit comments

Comments
 (0)