-
Notifications
You must be signed in to change notification settings - Fork 55
Add flexible aggregate analysis layer
#696
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the
aggregateanalysis which can aggregate one or more mapped columns grouped by one or more other columns. The aggregation functions can be chosen freely and the plotting function should just be picked as usual withvisual, so it's a very flexible analysis layer. The reason for this is that it's usually a bit annoying having to add data wrangling just for some simple visualizations that should be done on the fly, where you are not interested in keeping the aggregated data around. This way you don't have to come up with a variable name for it, plus it works with all table inputs and not just the typicalDataFrame.For example, let's say we have some categories and associated measurements. We can plot these as a normal scatter:
Let's say we want to show the median of each group. We can do this with
aggregate. Every mapped column needs to be either a grouping column or an aggregated column. Grouping columns are denoted by a:.Each column can only have one function applied, but this function may return multiple values per group, for example as a tuple. There can then be multiple functions that are applied on the result, each of which can be assigned to a different output mapping. This can be used, for example, to draw error bars or confidence intervals. Let's compute the 25th and 75th percentiles and draw the interval.
With
=> 2and=> 3we assign the first and second quantile to positional mappings 2 and 3 forRangebars. If you don't specify a remapping, the initial mapping is kept, but there can only be one output assigned to a mapping.In this case, it might look nice to apply a dodge, so both components can be discriminated better.
Grouping by multiple mappings also works, for example to compute a heatmap by summing all values of a given group (the empty cells are combinations of x and y that don't exist by chance):
Additionally, the outputs can be renamed with the pair syntax, plus you can assign a scale id like with a normal
mapping, becauseaggregatefreely creates new mapped columns: