You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In R there is the pipe operator "%>%" which applies the function after the operator on the data before the operator. Pandas also follows this philosophy of method chaining. There is also a pipe function. Here is a good comparison of R vs pandas: https://stmorse.github.io/journal/tidyverse-style-pandas.html
The old style. Execution from right to left or with pipe function.
In [3]: np.mean(np.sum(df))
Out[3]: 3.0In [4]: df.pipe(np.sum).pipe(np.mean)
Out[4]: 3.0
With the pipe operator. Execution from left to right with pipe operator.
In [5]: df>>np.sum>>np.meanOut[5]: 3.0In [6]: df>>printAB002113
I think the pipe operator makes it much more minimal.
API breaking implications
See above.
Describe alternatives you've considered
I picked the binary shift operator, because it is not currently used within pandas. I think it resembles a pipe the best.
Additional context
This does not work out of the box if the function takes additional argumements. One could use a lambda function, but that does not look clean. I think this is also the bigget downfall of this proposal.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem?
In R there is the pipe operator "%>%" which applies the function after the operator on the data before the operator. Pandas also follows this philosophy of method chaining. There is also a pipe function. Here is a good comparison of R vs pandas: https://stmorse.github.io/journal/tidyverse-style-pandas.html
Pandas is missing a stylish pipe operator.
Describe the solution you'd like
The old style. Execution from right to left or with pipe function.
With the pipe operator. Execution from left to right with pipe operator.
I think the pipe operator makes it much more minimal.
API breaking implications
See above.
Describe alternatives you've considered
I picked the binary shift operator, because it is not currently used within pandas. I think it resembles a pipe the best.
Additional context
This does not work out of the box if the function takes additional argumements. One could use a lambda function, but that does not look clean. I think this is also the bigget downfall of this proposal.
The text was updated successfully, but these errors were encountered: