Skip to content

Instantly share code, notes, and snippets.

@Ken-Kuroki
Last active February 10, 2020 18:52
Show Gist options
  • Save Ken-Kuroki/50827293f0ff5c9081244322ae0777de to your computer and use it in GitHub Desktop.
Save Ken-Kuroki/50827293f0ff5c9081244322ae0777de to your computer and use it in GitHub Desktop.
How to exchange data between Python, R, and Julia

Here's how to transfer your data frames between Python, R, and Julia by using Feather format. An article The Best Format to Save Pandas Data provides speed comparisons with other formats and concludes Feather is the best format to store data for a short term.

Note for pandas users: Feather doesn't support data frames with a custom index. Execute df.reset_index() before writing your data in a Feather file if you store anything in the pandas index.

Python

import pandas as pd
import feather

# read
df = feather.read_dataframe("foobar.feather")

# write
feather.write_dataframe(df, "foobar.feather")

R

library(feather)

# read
df <- read_feather("foobar.feather")

# write
write_feather(df, "foobar.feather")

Julia

using DataFrames
using Feather

# read
df = Feather.read("foobar.feather")

# write
Feather.write("foobar.feather", df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment