【发布时间】:2013-09-10 01:21:02
【问题描述】:
第一次使用 Python 用户,我迷路了。我需要从一个列表中创建一个表格,显示每日温度和截至当天的运行平均温度。
xData = arange(1,32)
tData = [86,87,84,86,86,86,84,83,90,89,88,85,86,79,83,81, \
75,80,81,85,81,88,89,87,84,85,86,88,88,90,90]
avg = [86.] # First value for monthly avg high temp is just the Day 1 temp
【问题讨论】:
-
你卡在哪里了?你试过什么?
-
我只是不知道如何开始,让它成为一个运行平均值。我知道如何做一个“常规”平均值,我只是不知道如何让它成为一个“运行平均值”
-
什么版本的 Python?如果您可以等待 3.4,只需
import statistics,它是单行的。对于 3.1-3.3,您可以在 PyPI 上使用 the backport。否则,你得写几行代码。
标签: python moving-average