Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable pass through *args, **kwargs to function in GroupBy #1418

Closed
blip2 opened this issue Jun 6, 2012 · 4 comments
Closed

Enable pass through *args, **kwargs to function in GroupBy #1418

blip2 opened this issue Jun 6, 2012 · 4 comments
Labels

Comments

@blip2
Copy link

blip2 commented Jun 6, 2012

Similar to: #376

@wesm
Copy link
Member

wesm commented Jun 6, 2012

Could you explain what you mean / give an example?

@blip2
Copy link
Author

blip2 commented Jun 7, 2012

Here would be my desired usage to group a timeseries by minutes (to a specific date):

def minutes(date,group_to):
    time = date.strftime("%H:%M:%S")
    date = group_to.strftime("%Y-%m-%d")
    dt = datetime.strptime(date + " " + time, "%Y-%m-%d %H:%M:%S")
    return dt

window = data.groupby(minutes,group_to=some_date)

If there is a neater way to do this, please help!

@dalejung
Copy link
Contributor

dalejung commented Jun 7, 2012

minutes = lambda date, group_to: datetime.combine(group_to, date.time())
df.groupby(lambda date: minutes(date, some_date))

You would throw around lambda, partials, etc. To be honest, I thought pass through would be something I wanted and monkey-patched it in, but it's less clear what you're doing when you re-read the code later on.

@blip2 blip2 closed this as completed Jun 7, 2012
@blip2
Copy link
Author

blip2 commented Jun 7, 2012

Excellent, that'll do nicely. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants