Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to convert R data.table to pandas.DataFrame? [closed]

what would be the in your experience the best way to convert R data.table frame into a Pandas dataframe? I looked into different options, like hdf5 (3 libraries), rpy (does not seem to have this functionality?), and decided to ask the esteemed community: do you have any code snippets to do it the fastest, easiest, and the most reliable way?

R and python code snippets would be preferable.

like image 949
Andrey Vykhodtsev Avatar asked Nov 09 '22 10:11

Andrey Vykhodtsev


1 Answers

It seems that for now the simplest and most reliable way to do so is via csv

R:

write.csv(df, file)

Python:

df = pd.read_csv(file, na_values=['NA'])
like image 146
Andrey Vykhodtsev Avatar answered Nov 14 '22 23:11

Andrey Vykhodtsev