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

computations.Percent seems like it would be a good addition #490

Closed
palewire opened this issue Feb 11, 2016 · 2 comments
Closed

computations.Percent seems like it would be a good addition #490

palewire opened this issue Feb 11, 2016 · 2 comments
Labels

Comments

@palewire
Copy link
Contributor

Unless I'm missing it, right now you have to do something like this loop through a table and add a new calculated column with a percentage value.

table = table.compute([
    ('percent', agate.Formula(agate.Number(), lambda row: row['count']/total))
])

To me something roughly like this might be nicer:

total = 100
table = table.compute(('percent', agate.Percent('count', total))

Crazy? If you like the idea, I'd be happy to take a stab at contributing it.

@palewire palewire changed the title computations.Percentage seems like it would be a good addition computations.Percent seems like it would be a good addition Feb 11, 2016
@onyxfish
Copy link
Collaborator

Looks good to me! It would be cool if total defaulted to None and in that case it ran a Sum and used the total of the column.

@palewire
Copy link
Contributor Author

Okay. I will take a run at it.

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