如何用计算机计算平均年龄,使用Excel计算每日平均值(Calculating Daily Averages with Excel)...

使用Excel计算每日平均值(Calculating Daily Averages with Excel)

在给定时期内计算整数的每日平均值的最佳方法是什么。

例如:

Jan 1st | 456

Jan 2nd | 238

Etc all the way to the current date.

最终的结果是,我将获得YTD的当前日平均值,所以像这样:

Monday - average of 250

Tuesday - average of 183

基于YTD数据。 这是一列日期和一列数字。

任何帮助,将不胜感激。

What would be the best way to calculate the daily average of a whole number over a given period.

For example:

Jan 1st | 456

Jan 2nd | 238

Etc all the way to the current date.

The end result is I would have the current daily average for the YTD, so like this :

Monday - average of 250

Tuesday - average of 183

Based on the YTD data. It's one column of dates and one column of numbers.

Any help would be appreciated.

原文:https://stackoverflow.com/questions/37535256

更新时间:2020-04-04 20:04

相关问答

尝试: =AVERAGEIF('analyse-logs'!A:A;A1;'analyse-logs'!B:B) 问候 Try: =AVERAGEIF('analyse-logs'!A:A;A1;'analyse-logs'!B:B) Regards

使用熊猫肯定是要走的路。 至少有两种方法可以按“一年中的某一天”进行分组,您可以将一年中的数字日作为字符串或字符串monthday组合进行monthday如下所示: import pandas as pd

import numpy as np

df = pd.DataFrame(index=pd.date_range('2000-01-01', '2010-12-31'))

df['vals'] = np.random.randint(1, 6, df.shape[0])

print(df.

...

你想要的公式是 =(100*A2/A$1 + 100 *C2/C$1)/2

然后向下选择所有列D,然后编辑 - >填充 相对引用A2将在每行中更改为新行,但A $ 1是绝对引用,并将保留为第1行中的值。 您也可以使用为您填写的数组公式来执行此操作。 请参阅MS文章 The formula you want is =(100*A2/A$1 + 100 *C2/C$1)/2

and the select all of column D downwards and then edit->fill d

...

只需使用SQL。 忘记ActiveRecord方式,SQL更适合这样的事情。 如果您想在模型中保留逻辑,只需在模型中创建一个新方法 Just use SQL. Forget the ActiveRecord way, SQL is better for something like this. If you want to keep your logic in your model just create a new method in your model

让我们假设您有一个标题行,您的数据来自A2:B2000。 在D列中,生成您希望每日最大值的日期列表。 让我们假设你在D2的第一次约会 在与第一个日期相邻的E2中,您希望找到使用以下公式的最大值: =AGGREGATE(14,6,$B$2:$B2000*(INT($A$2:$A$2000)=$D2),1)

将该公式复制到您想知道最大值的每个日期旁边。 警告: 对于没有数据的日期,返回的值为0。 对于每日平均值,您在F2中使用以下内容: =AVERAGEIFS($B$2:$B$2000,$A$2:

...

您必须将该函数保存在名为calc_avg.m的单独文件中(在MATLAB路径的当前文件夹或文件夹中),并从单独的脚本或命令行运行它 pathName = 'path/to/file';

[Daily, Hourly] = calc_avg(pathName)

您可能会收到错误,因为您尝试使用Run(f5)在编辑器中将该函数作为脚本运行。 You have to save the function in a separate file called calc_avg.m (in a current

...

答案是在内部平均值上使用SUBTOTAL() 。 这将返回一列平均值,因此外部AVERAGE()将具有正确的行为。 {=AVERAGE(SUBTOTAL(1,OFFSET(A21,-4+1-ROW(OFFSET(A1,0,0,8))+1,0,4)))}

原始解决方案不起作用的原因是因为内部AVERAGE只是取所有数组的总平均值,而不是返回其各个平均值的列。 当你需要做这种事情时,我发现这个SUBTOTAL()技巧很有用。 Answer is to use SUBTOTAL() on the in

...

选项1 from cytoolz.dicttoolz import merge

ncols = df.select_dtypes([np.number]).columns

ocols = df.columns.difference(ncols)

df.index = pd.to_datetime(df.index)

d = merge(

{c: 'mean' for c in ncols},

{c: lambda x: pd.value_counts(x).index[0]

...

如果您可以在类别列之前使用帮助列,则可以使用以下内容: 以下是使用的公式: 助手栏将根据类别为行编号,并增加每个类别更改的编号。 平均列使用averageif公式,该公式使用编号作为标准。 您可以进一步格式化助手列,使其不可见。 If you can use a helper column before the category column, you can have something like this: Here are the formulas used: The helper colu

...

要计算实际平均值而不将其向下舍入,请使用float。 你还需要一对额外的括号,否则它将是y / 2而不是(x + y / 2)。 至于那个错误,我不确定你在Listofvalues列表中使用的是什么作为输入,以下对我来说很好。 Averagelist = []

Listofvalues1 = [1,2]

Listofvalues2 = [6,7]

for i, x in enumerate(Listofvalues1):

for j, y in enumerate(Listofvalue

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值