5 ms·
> prototyping data-driven applications, Python would probably be better I would disagree. Python's libraries are really reimplementing R in Python (Mainly Pand
by baldfat 11y ago
> prototyping data-driven applications, Python would probably be better
I would disagree. Python's libraries are really reimplementing R in Python (Mainly Pandas). I find R to be very flexible and especially in the last 5 years with Hadley Wickham's libraries things are concise and very powerful.
Please look at dplyr and see how this new way fo doing R works. Especially with piping with %>%. https://cran.rstudio.com/web/packages/dplyr/vignettes/introduction.html https://cran.rstudio.com/web/packages/dplyr/vignettes/introd...
Code in R can look like this beautiful code (If you don't code in R and I would expect anyone can see what is happening) This is why I disagree that prototyping in Python would be better.:
flights %>%
group_by(year, month, day) %>%
select(arr_delay, dep_delay)
summarise(
arr = mean(arr_delay, na.rm = TRUE),
dep = mean(dep_delay, na.rm = TRUE)) %>%
filter(arr > 30 | dep > 30)
Python has .pipe but I find it strange it goes to the new line before the items.
Python Code:
>>> (df.pipe(h)
... .pipe(g, arg1=a)
... .pipe((f, 'arg2'), arg1=a, arg3=c)
... )
- avdempsey 11y agoI find the following Pandas code pretty easy to read: (df .groupby(['a', 'b', 'c'], as_index=False) .agg({'d': sum, 'e': mean, 'f', np.std}) .assign(g=lambda x: x.a / x.c) .query("g > 0.05") .merge(df2, on='a')) There are now methods in pandas to do pretty much anything, so you can chain them together into one easy-to-read manipulation without lots of intermediate variables.