You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In v0.16.0, the ``pandas.rpy`` interface has been **deprecated and will be
19
-
removed in a future version**. Similar functionality can be accessed
20
-
through the `rpy2 <https://rpy2.readthedocs.io/>`__ project.
21
-
See the :ref:`updating <rpy.updating>` section for a guide to port your
22
-
code from the ``pandas.rpy`` to ``rpy2`` functions.
23
-
24
-
25
-
.. _rpy.updating:
26
-
27
-
Updating your code to use rpy2 functions
28
-
----------------------------------------
29
-
30
-
In v0.16.0, the ``pandas.rpy`` module has been **deprecated** and users are
31
-
pointed to the similar functionality in ``rpy2`` itself (rpy2 >= 2.4).
16
+
Up to pandas 0.19, a ``pandas.rpy`` module existed with functionality to
17
+
convert between pandas and ``rpy2`` objects. This functionality now lives in
18
+
the `rpy2 <https://rpy2.readthedocs.io/>`__ project itself.
19
+
See the `updating section <http://pandas.pydata.org/pandas-docs/version/0.19.0/r_interface.html#updating-your-code-to-use-rpy2-functions>`__
20
+
of the previous documentation for a guide to port your code from the
21
+
removed ``pandas.rpy`` to ``rpy2`` functions.
32
22
33
-
Instead of importing ``import pandas.rpy.common as com``, the following imports
34
-
should be done to activate the pandas conversion support in rpy2::
35
-
36
-
from rpy2.robjects import pandas2ri
37
-
pandas2ri.activate()
38
23
24
+
`rpy2 <http://rpy2.bitbucket.org/>`__ is an interface to R running embedded in a Python process, and also includes functionality to deal with pandas DataFrames.
39
25
Converting data frames back and forth between rpy2 and pandas should be largely
40
26
automated (no need to convert explicitly, it will be done on the fly in most
41
27
rpy2 functions).
42
-
43
28
To convert explicitly, the functions are ``pandas2ri.py2ri()`` and
44
-
``pandas2ri.ri2py()``. So these functions can be used to replace the existing
45
-
functions in pandas:
46
-
47
-
- ``com.convert_to_r_dataframe(df)`` should be replaced with ``pandas2ri.py2ri(df)``
48
-
- ``com.convert_robj(rdf)`` should be replaced with ``pandas2ri.ri2py(rdf)``
49
-
50
-
Note: these functions are for the latest version (rpy2 2.5.x) and were called
51
-
``pandas2ri.pandas2ri()`` and ``pandas2ri.ri2pandas()`` previously.
52
-
53
-
Some of the other functionality in `pandas.rpy` can be replaced easily as well.
54
-
For example to load R data as done with the ``load_data`` function, the
55
-
current method::
56
-
57
-
df_iris = com.load_data('iris')
58
-
59
-
can be replaced with::
60
-
61
-
from rpy2.robjects import r
62
-
r.data('iris')
63
-
df_iris = pandas2ri.ri2py(r[name])
64
-
65
-
The ``convert_to_r_matrix`` function can be replaced by the normal
66
-
``pandas2ri.py2ri`` to convert dataframes, with a subsequent call to R
67
-
``as.matrix`` function.
68
-
69
-
.. warning::
70
-
71
-
Not all conversion functions in rpy2 are working exactly the same as the
72
-
current methods in pandas. If you experience problems or limitations in
73
-
comparison to the ones in pandas, please report this at the
0 commit comments