question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Percentage rather than counts

See original GitHub issue

I’m trying to create a bar plot aggregating the data points into percentages. So I would like to do something like

plot = alt.Chart(data).mark_bar().encode(
    x = "CategoricalVariable",
    y = "count(*)/sum(count(*))")
)

but for the past hours I’ve completely failed to find a way of how to do that.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

0reactions
jakevdpcommented, Apr 22, 2020

It looks like you want something like this (not tested):

alt.Chart(
    allLikelihoods
 ).transform_joinaggregate(
    groupby = ['phi'], phiLikelihood = 'sum(logLikelihood)'
 ).transform_calculate(
    logPhi = 'exp(datum.phiLikelihood)'
).transform_joinaggregate(
    totalLikelihod = 'sum(logPhi)'
).transform_calculate(
   logTotalLikelihood = 'log(totalLikelihood)'
)
Read more comments on GitHub >

github_iconTop Results From Across the Web

When is it appropriate to use counts and when is it appropriate ...
If the number of people in the groups are the same, then comparing counts and comparing percentages are comparable. Example 2. Why use...
Read more >
Are Percentages Always Better Than Counts to Measure ...
The debate continues about whether percentages are always better to understand performance, rather than counts.
Read more >
Show percent % instead of counts in charts of categorical ...
I'm looking for a way to get ggplot to display the percentage of values in that category. Of course, it is possible to...
Read more >
VIDEO: “Percentages versus counts” (1:16) - cs.utsa.edu
Percentages are better for comparisons of data sets of different sizes. If you don't multiply by 100 after dividing your counts by the...
Read more >
When to Use a Count, a Percentage, or an Average to ...
A percentage would tell us only whether or not a result was achieved, rather that the degree to which that result was achieved....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found