From dc979fb9333b367503e759b48ce72eb2d9d95d46 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Fri, 16 Nov 2018 10:35:31 +0000 Subject: [PATCH 1/4] Removing rpy2 documentation --- ci/deps/travis-36-doc.yaml | 4 -- doc/source/index.rst.template | 1 - doc/source/r_interface.rst | 76 ----------------------------------- 3 files changed, 81 deletions(-) delete mode 100644 doc/source/r_interface.rst diff --git a/ci/deps/travis-36-doc.yaml b/ci/deps/travis-36-doc.yaml index f79fcb11c179f..fb54c784d6fac 100644 --- a/ci/deps/travis-36-doc.yaml +++ b/ci/deps/travis-36-doc.yaml @@ -2,7 +2,6 @@ name: pandas channels: - defaults - conda-forge - - r dependencies: - beautifulsoup4 - bottleneck @@ -31,14 +30,11 @@ dependencies: - python-snappy - python=3.6* - pytz - - r - - rpy2 - scipy - seaborn - sphinx - sqlalchemy - statsmodels - - tzlocal - xarray - xlrd - xlsxwriter diff --git a/doc/source/index.rst.template b/doc/source/index.rst.template index 38f73f8617ced..1b3248c64f795 100644 --- a/doc/source/index.rst.template +++ b/doc/source/index.rst.template @@ -145,7 +145,6 @@ See the package overview for more detail about what's in the library. enhancingperf sparse gotchas - r_interface ecosystem comparison_with_r comparison_with_sql diff --git a/doc/source/r_interface.rst b/doc/source/r_interface.rst deleted file mode 100644 index 88634d7f75c63..0000000000000 --- a/doc/source/r_interface.rst +++ /dev/null @@ -1,76 +0,0 @@ -.. _rpy: - -.. ipython:: python - :suppress: - - import pandas as pd - pd.options.display.max_rows = 15 - - -****************** -rpy2 / R interface -****************** - -.. warning:: - - Up to pandas 0.19, a ``pandas.rpy`` module existed with functionality to - convert between pandas and ``rpy2`` objects. This functionality now lives in - the `rpy2 `__ project itself. - See the `updating section `__ - of the previous documentation for a guide to port your code from the - removed ``pandas.rpy`` to ``rpy2`` functions. - - -`rpy2 `__ is an interface to R running embedded in a Python process, and also includes functionality to deal with pandas DataFrames. -Converting data frames back and forth between rpy2 and pandas should be largely -automated (no need to convert explicitly, it will be done on the fly in most -rpy2 functions). -To convert explicitly, the functions are ``pandas2ri.py2ri()`` and -``pandas2ri.ri2py()``. - - -See also the documentation of the `rpy2 `__ project: https://rpy2.readthedocs.io. - -In the remainder of this page, a few examples of explicit conversion is given. The pandas conversion of rpy2 needs first to be activated: - -.. ipython:: python - - from rpy2.robjects import r, pandas2ri - pandas2ri.activate() - -Transferring R data sets into Python ------------------------------------- - -Once the pandas conversion is activated (``pandas2ri.activate()``), many conversions -of R to pandas objects will be done automatically. For example, to obtain the 'iris' dataset as a pandas DataFrame: - -.. ipython:: python - - r.data('iris') - r['iris'].head() - -If the pandas conversion was not activated, the above could also be accomplished -by explicitly converting it with the ``pandas2ri.ri2py`` function -(``pandas2ri.ri2py(r['iris'])``). - -Converting DataFrames into R objects ------------------------------------- - -The ``pandas2ri.py2ri`` function support the reverse operation to convert -DataFrames into the equivalent R object (that is, **data.frame**): - -.. ipython:: python - - df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C':[7,8,9]}, - index=["one", "two", "three"]) - r_dataframe = pandas2ri.py2ri(df) - print(type(r_dataframe)) - print(r_dataframe) - -The DataFrame's index is stored as the ``rownames`` attribute of the -data.frame instance. - - -.. - Calling R functions with pandas objects - High-level interface to R estimators From 4f558dbd3cae0f7a0e473ce93c2225ddc7b07c9c Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Sun, 18 Nov 2018 00:18:50 +0000 Subject: [PATCH 2/4] Restoring r_interface file with ipython blocks changed to regular python blocks --- doc/source/r_interface.rst | 88 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 doc/source/r_interface.rst diff --git a/doc/source/r_interface.rst b/doc/source/r_interface.rst new file mode 100644 index 0000000000000..bdba0013cd1f8 --- /dev/null +++ b/doc/source/r_interface.rst @@ -0,0 +1,88 @@ +.. _rpy: + +.. ipython:: python + :suppress: + + import pandas as pd + pd.options.display.max_rows = 15 + + +****************** +rpy2 / R interface +****************** + +.. warning:: + + Up to pandas 0.19, a ``pandas.rpy`` module existed with functionality to + convert between pandas and ``rpy2`` objects. This functionality now lives in + the `rpy2 `__ project itself. + See the `updating section `__ + of the previous documentation for a guide to port your code from the + removed ``pandas.rpy`` to ``rpy2`` functions. + + +`rpy2 `__ is an interface to R running embedded in a Python process, and also includes functionality to deal with pandas DataFrames. +Converting data frames back and forth between rpy2 and pandas should be largely +automated (no need to convert explicitly, it will be done on the fly in most +rpy2 functions). +To convert explicitly, the functions are ``pandas2ri.py2ri()`` and +``pandas2ri.ri2py()``. + + +See also the documentation of the `rpy2 `__ project: https://rpy2.readthedocs.io. + +In the remainder of this page, a few examples of explicit conversion is given. The pandas conversion of rpy2 needs first to be activated: + +.. code-block:: python + + >>> from rpy2.robjects import r, pandas2ri # doctest: +SKIP + >>> pandas2ri.activate() # doctest: +SKIP + +Transferring R data sets into Python +------------------------------------ + +Once the pandas conversion is activated (``pandas2ri.activate()``), many conversions +of R to pandas objects will be done automatically. For example, to obtain the 'iris' dataset as a pandas DataFrame: + +.. code-block:: python + + >>> r.data('iris') # doctest: +SKIP + >>> r['iris'].head() # doctest: +SKIP + Sepal.Length Sepal.Width Petal.Length Petal.Width Species + 0 5.1 3.5 1.4 0.2 setosa + 1 4.9 3.0 1.4 0.2 setosa + 2 4.7 3.2 1.3 0.2 setosa + 3 4.6 3.1 1.5 0.2 setosa + 4 5.0 3.6 1.4 0.2 setosa + +If the pandas conversion was not activated, the above could also be accomplished +by explicitly converting it with the ``pandas2ri.ri2py`` function +(``pandas2ri.ri2py(r['iris'])``). + +Converting DataFrames into R objects +------------------------------------ + +The ``pandas2ri.py2ri`` function support the reverse operation to convert +DataFrames into the equivalent R object (that is, **data.frame**): + +.. code-block:: python + + >>> df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [7, 8, 9]}, + ... index=["one", "two", "three"]) # doctest: +SKIP + >>> r_dataframe = pandas2ri.py2ri(df) # doctest: +SKIP + >>> print(type(r_dataframe)) # doctest: +SKIP + + >>> print(r_dataframe) # doctest: +SKIP + A B C + one 1 4 7 + two 2 5 8 + three 3 6 9 + + +The DataFrame's index is stored as the ``rownames`` attribute of the +data.frame instance. + + +.. + Calling R functions with pandas objects + High-level interface to R estimators From 53a56f4ef229324f23ad0b632215a15505853c44 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Sun, 18 Nov 2018 00:22:00 +0000 Subject: [PATCH 3/4] Restoring r_interface in index --- doc/source/index.rst.template | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/index.rst.template b/doc/source/index.rst.template index 1b3248c64f795..38f73f8617ced 100644 --- a/doc/source/index.rst.template +++ b/doc/source/index.rst.template @@ -145,6 +145,7 @@ See the package overview for more detail about what's in the library. enhancingperf sparse gotchas + r_interface ecosystem comparison_with_r comparison_with_sql From 52f3e6847591c91d5f374168a7fee4d428f8c593 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Mon, 19 Nov 2018 11:18:42 +0000 Subject: [PATCH 4/4] Fixing linting error, and wrong indentation --- doc/source/r_interface.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/source/r_interface.rst b/doc/source/r_interface.rst index bdba0013cd1f8..d0b2601668069 100644 --- a/doc/source/r_interface.rst +++ b/doc/source/r_interface.rst @@ -35,8 +35,8 @@ In the remainder of this page, a few examples of explicit conversion is given. T .. code-block:: python - >>> from rpy2.robjects import r, pandas2ri # doctest: +SKIP - >>> pandas2ri.activate() # doctest: +SKIP + >>> from rpy2.robjects import pandas2ri # doctest: +SKIP + >>> pandas2ri.activate() # doctest: +SKIP Transferring R data sets into Python ------------------------------------ @@ -46,6 +46,7 @@ of R to pandas objects will be done automatically. For example, to obtain the 'i .. code-block:: python + >>> from rpy2.robjects import r # doctest: +SKIP >>> r.data('iris') # doctest: +SKIP >>> r['iris'].head() # doctest: +SKIP Sepal.Length Sepal.Width Petal.Length Petal.Width Species