Re:Dplython: Dplyr for Python
by carljv on Tuesday March 22, 2016 @11:52AM
(#11337427)
This is an interesting project, and it's illuminating to see what it takes to emulate some R features in Python (custom infix ops, non-standard evaluation, dataframes as namespaces/envrionments, etc.)
But I feel like it would be better to use method chaining for the piping of transformation rather than overloading dunder method operators. It would preserve one of the nice things about dplyr -- composing complicated transformations from a simple vocabulary, but more pythonic. This is a relative weakness I see in the design of pandas and would love to see ported over.
But also, dplyr is a thing that really goes beyond pandas. It's really an elegant, SQL-like DSL for transforming (mostly) arbitrary data. In this way it's more like LINQ than a specific implementation/API of a data structure.
It looks like both Dplython and pandas-ply are missing one of (what I think is) the core value propositions of dplyr: the ability to use the same abstractions on local data and on remote data, with execution against the remote source happening lazily such that the entire table doesn't need to be downloaded in order to run a filter locally.
(Of course, I may be biased in that I work on a commercial product which also has this characteristic.)
Re:Dplython: Dplyr for Python
by tanlermin on Tuesday March 22, 2016 @11:38AM
(#11337342)
Blaze has already spent alot of time on this usecase and seems quite promising for a whole host of other reasons. Perhaps it would be best to combine forces?
Re:Dplython: Dplyr for Python
by capybara on Tuesday March 22, 2016 @03:07PM
(#11339112)
The idea of putting the column names into the namespace is very interesting, and blaze looks pretty promising overall as a way to connect to big data sources.
Re:Dplython: Dplyr for Python
by andrewla on Tuesday March 22, 2016 @09:20AM
(#11336325)
At least from a historical perspective, dplyr introduced the `%.%` at a time when Hadley was not aware of the existence of magrittr; later, it became clear that the work had already been done, so dplyr was retrofitted to use magrittr and %>%, which was easier to type because you don't have to let go of the shift key..
That said, the hoops you have to jump through when interfacing with stock R code and dplyr make me think that having an operator that is less generic than `%>%` makes sense -- `X %>% foo()` is equivalent to `foo(X)`; except if it isn't -- `X %>% plot(x~y, data=.)` is not equivalent to `plot(X, x~y, data=.)`. And sometimes you need tricks like `X %>% { plot(.$x, .$y) }` to work around the nonobvious behaviors.
I find most impressive the work that this project did to emulate the lazy evaluation that is a hallmark of dplyr. I wasn't aware that python had anything like this ability.
Re:Dplython: Dplyr for Python
by baldfat on Tuesday March 22, 2016 @12:13PM
(#11337583)
Well Python and Panda has been making an R equivalent for a while now, Pandas. Pandas and other work has made a Python a good choice for doing data science work (Though I prefer R and started in Python years ago). The Pandas and Python Data Science developers have been awesome. Now the Python Community not so much (In regards to flaming R).
But I feel like it would be better to use method chaining for the piping of transformation rather than overloading dunder method operators. It would preserve one of the nice things about dplyr -- composing complicated transformations from a simple vocabulary, but more pythonic. This is a relative weakness I see in the design of pandas and would love to see ported over.
But also, dplyr is a thing that really goes beyond pandas. It's really an elegant, SQL-like DSL for transforming (mostly) arbitrary data. In this way it's more like LINQ than a specific implementation/API of a data structure.
(Of course, I may be biased in that I work on a commercial product which also has this characteristic.)
edit: After some stalking, I see you work on PowerQuery. Great product! Improving the SQL editing capabilities would make it much better!
Also see this:
https://github.com/blaze/blaze/pull/484
"R package to bring forward-piping features ala F#'s |> operator."
That said, the hoops you have to jump through when interfacing with stock R code and dplyr make me think that having an operator that is less generic than `%>%` makes sense -- `X %>% foo()` is equivalent to `foo(X)`; except if it isn't -- `X %>% plot(x~y, data=.)` is not equivalent to `plot(X, x~y, data=.)`. And sometimes you need tricks like `X %>% { plot(.$x, .$y) }` to work around the nonobvious behaviors.
I find most impressive the work that this project did to emulate the lazy evaluation that is a hallmark of dplyr. I wasn't aware that python had anything like this ability.