GShotwell opened a new issue #83:
URL: https://github.com/apache/arrow-cookbook/issues/83


   It would be great if there were a way to sample from an arrow dataset. I put 
together this somewhat hacky example, but I bet there's some thing a bit more 
elegant..
   
   ```
   library(arrow)
   library(dplyr)
   library(nycflights13)
   
   flights <- nycflights13::flights
   
   flights$id <- seq_len(nrow(flights))
   
   for(i in unique(flights$month)) {
     out <- filter(flights, month == i)
     arrow::write_parquet(out, paste0("flight_ds/", i, ".parquet"))
   }
   
   ds <- arrow::open_dataset("flight_ds")
   
   sample <- sample(flights$id, 100)
   
   ds %>% 
     filter(id %in% sample) %>% 
     collect()
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to