title: How to export a list of dataframes from R to Python?
body: <p>I'm currently working with functional MRI data in R but I need to import it to Python for some faster analysis. How can I do that in an efficient way?</p>
  
  <p>I currently have in R a list of 198135 dataframes. All of them have 5 variables and 84 observations of connectivity between brain regions. I need to display the same 198135 dataframes in Python for running some specific analysis there (with the same structure than in R: one object that contains all dataframes separately). </p>
  
  <p>Initially I tried exporting a .RDS file from R and then importing it to Python using "pyreadr", but I'm getting empty objects in every atempt with "pyreadr.read_r()" function. </p>
  
  <p>My other method was to save every dataframe of the R list as a separate .csv file, and then importing them to Python. In that way I could get what I wanted (I tried it with 100 dataframes only for trying the code). The problem with this method is that is highly inefficient and slow. </p>
  
  <p>I found several answers to similar problems, but most of them were to merge all dataframes and load it as a unique .csv into Python, which is not the solution I need.</p>
  
  <p>Is there some more efficient way to do this process, without altering the data structure that I mentioned?</p>
  
  <p>Thanks for your help!</p>
  
  <pre><code># This is the code in R for an example
  
  a &lt;- as.data.frame(cbind(c(1:3), c(1:3), c(4:6), c(7:9)))
  b &lt;- as.data.frame(cbind(c(11:13), c(21:23), c(64:66), c(77:79)))
  c &lt;- as.data.frame(cbind(c(31:33), c(61:63), c(34:36), c(57:59)))
  d &lt;- as.data.frame(cbind(c(12:14), c(13:15), c(54:56), c(67:69)))
  e &lt;- as.data.frame(cbind(c(31:33), c(51:53), c(54:56), c(37:39)))
  
  somelist_of_df &lt;- list(a,b,c,d,e)
  
  
  saveRDS(somelist_of_df, "somefile.rds") 
  </code></pre>
  
  <pre><code>## This is the function I used from pyreadr in Python
  
  
  import pyreadr
  
  results = pyreadr.read_r('/somepath/somefile.rds')
  
  
  </code></pre>