Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d28afd3 commit cc5cd4dCopy full SHA for cc5cd4d
Lib/statistics.py
@@ -505,13 +505,11 @@ def fmean(data, weights=None):
505
n = len(data)
506
except TypeError:
507
# Handle iterators that do not define __len__().
508
- n = 0
509
- def count(iterable):
510
- nonlocal n
511
- for n, x in enumerate(iterable, start=1):
512
- yield x
513
- data = count(data)
514
- total = fsum(data)
+ counter = count()
+ total = fsum(map(itemgetter(0), zip(data, counter)))
+ n = next(counter)
+ else:
+ total = fsum(data)
515
if not n:
516
raise StatisticsError('fmean requires at least one data point')
517
return total / n
0 commit comments