Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEPR: deprecate pandas.rpy (GH9602) #9612

Merged
merged 1 commit into from
Mar 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions doc/source/r_interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http://rpy.sourceforge.net/>`_ 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,
Expand Down
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.13.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
4 changes: 4 additions & 0 deletions doc/source/whatsnew/v0.16.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/datalyze-solutions/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 <http://rpy.sourceforge.net/>`_ project (:issue:`9602`)


.. _whatsnew_0160.prior_deprecations:

Removal of prior version deprecations/changes
Expand Down
9 changes: 9 additions & 0 deletions pandas/rpy/__init__.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
102 changes: 0 additions & 102 deletions pandas/stats/tests/test_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
1 change: 0 additions & 1 deletion pandas/util/print_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__),
Expand Down