Search code examples
pythonrfeather

Python & R- feather package - How to change default write directory?


I gave up after Googling 1+ Hour. Here my objective is store my feather files from R and Python different dictory (other than default "C:\Users\murali"). I am using Jupyter Notebooks for both R and Python

Thank you so much for your help!!

R code

library(feather)
path <- "my_data.feather5"
write_feather(mtcars, path)
df <- read_feather(path)

Python Coded

import feather
import pandas as pd
import numpy as np
arr = np.random.randn(10000) # 10% nulls
arr[::10] = np.nan
df = pd.DataFrame({'column_{0}'.format(i): arr for i in range(10)})
feather.write_dataframe(df, 'test.feather')

Solution

  • In R (set the working directory to a new default value):

    setwd("C:\Users\murali")
    

    In Python :

    os.chdir("C:\Users\murali")