Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (50.2k points)

I converted a pandas df to r using the below:

import pandas as pd

import pandas.rpy.common as com

import rpy2.robjects as ro

from rpy2.robjects.packages import importr

rdf = com.convert_to_r_dataframe(df)

How do I convert rdf back to a pandas df?

df = f(rdf) ?

1 Answer

0 votes
by (107k points)

It can be done with pandas2ri.

Here is representation code for convert rpy dataframe (rdf) to pandas dataframe (pd_df):

from rpy2.robjects import pandas2ri

pd_df = pandas2ri.ri2py_dataframe(rdf)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...