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.

add average function

See original GitHub issue

It would be nice to be able to do ds.average() to compute weighted averages (e.g. for geo data). Of course this would require the axes to be in a predictable order. Or to give a weight per dimension…

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:23 (17 by maintainers)

github_iconTop GitHub Comments

2reactions
shoyercommented, May 11, 2016

I would suggest not using keyword arguments for weighted. Instead, just align based on the labels of the argument like regular xarray operations. So we’d write da.weighted(days_per_month(da.time)).mean()

2reactions
jhammancommented, May 11, 2016

@MaximilianR has suggested a groupby/rolling-like interface to weighted reductions.

da.weighted(weights=ds.dim).mean()
# or maybe
da.weighted(time=days_per_month(da.time)).mean()

I really like this idea, as does @shoyer. I’m going to close my PR in hopes of this becoming reality.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AVERAGE function - Microsoft Support
Average, which is the arithmetic mean, and is calculated by adding a group of numbers and then dividing by the count of those...
Read more >
Calculate the average of a group of numbers - Microsoft Support
Average This is the arithmetic mean, and is calculated by adding a group of numbers and then dividing by the count of those...
Read more >
How to Calculate Averages in Excel (7 Simple Ways) - GoSkills
The Excel AVERAGE function is used to generate a number that represents a typical value from a range, distribution, or list of numbers....
Read more >
How to Get Average with Excel Formulas - Contextures
The Excel AVERAGE function will calculate the average (arithmetic mean) for a specified set of numbers in an Excel spreadsheet.
Read more >
AVERAGE Function - How to Calculate Average in Excel
=AVERAGE(number1, [number2], …) · Number1 (required argument) – This is the first number of a cell reference or a range for which we...
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