Skip to content

Commit a17a03a

Browse files
DOC: correct rpy2 examples (GH15142) (pandas-dev#15450)
1 parent f65a641 commit a17a03a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

doc/source/r_interface.rst

+6-5
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,17 @@ In the remainder of this page, a few examples of explicit conversion is given. T
4141
Transferring R data sets into Python
4242
------------------------------------
4343

44-
The ``pandas2ri.ri2py`` function retrieves an R data set and converts it to the
45-
appropriate pandas object (most likely a DataFrame):
44+
Once the pandas conversion is activated (``pandas2ri.activate()``), many conversions
45+
of R to pandas objects will be done automatically. For example, to obtain the 'iris' dataset as a pandas DataFrame:
4646

4747
.. ipython:: python
4848
4949
r.data('iris')
50-
df_iris = pandas2ri.ri2py(r['iris'])
51-
df_iris.head()
50+
r['iris'].head()
5251
52+
If the pandas conversion was not activated, the above could also be accomplished
53+
by explicitly converting it with the ``pandas2ri.ri2py`` function
54+
(``pandas2ri.ri2py(r['iris'])``).
5355

5456
Converting DataFrames into R objects
5557
------------------------------------
@@ -65,7 +67,6 @@ DataFrames into the equivalent R object (that is, **data.frame**):
6567
print(type(r_dataframe))
6668
print(r_dataframe)
6769
68-
6970
The DataFrame's index is stored as the ``rownames`` attribute of the
7071
data.frame instance.
7172

0 commit comments

Comments
 (0)