kieferk / dfply

dplyr-style piping operations for pandas dataframes
GNU General Public License v3.0
889 stars 103 forks source link

Add ability to pass positional arguments to `summarize()` #70

Closed TariqAHassan closed 5 years ago

TariqAHassan commented 5 years ago

This PR adds the ability to pass positional arguments to summarize(). This is often very handy when scripting and one just wants to quickly see the result.

Example:

from dfply import *

diamonds >> summarize(X.price.mean())

#   unnamed_arg_0
# 0    3932.799722

In dplyr, summarize() will use the code as the column name if the user does not provide one. Apart from being difficult to replicate in Python (i.e., without non-standard evaluation), it can make for quite cumbersome column names. So instead, here I generate column names which correspond to the position of the args.

I am open to any ideas you may have.

sharpe5 commented 5 years ago

Thank you, and nice work!

On Mon, 17 Sep 2018 02:29 Tariq Hassan, notifications@github.com wrote:

This PR adds the ability to pass positional arguments to summarize(). This is often very handy when scripting and one just wants to quickly see the result.

Example:

from dfply import *

diamonds >> summarize(X.price.mean())

unnamed_arg_0

0 3932.799722

In dplyr, summarize() will use the code as the column name if the user does not provide one. Apart from being difficult to replicate in Python (i.e., without non-standard evaluation), it can make for quite cumbersome column names. So instead, here I generate column names which correspond to the position of the args.

I am open to any ideas you may have.

You can view, comment on, or merge this pull request online at:

https://github.com/kieferk/dfply/pull/70 Commit Summary

  • Add ability to pass positional arguments to summarize()
  • Add test for positional arguments
  • Merge branch 'master' of git://github.com/kieferk/dfply
  • Update test name

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kieferk/dfply/pull/70, or mute the thread https://github.com/notifications/unsubscribe-auth/ABOypIXhgncgPG97xXcZREi6ATQD4mvYks5ubvragaJpZM4WrJis .

kieferk commented 5 years ago

Looks good, thanks! Merging now.