我想将以下命令应用于数据组,其中组的数量符合最低计数标准。
db=table.groupby(['Type','Quarter'])["Price"].mean()
到目前为止,以下示例并未返回所需的结果。
db=table.groupby(['Type','Quarter']).filter(lambda group: group.size > 3).groupby(['Type','Quarter'])["SALE_PRC"].mean()
基本上我想找到([' Type',' Quarter'])群组的[" Price"]的平均值但仅限于记录数超过3个。
感谢任何帮助。 谢谢
答案 0 :(得分:1)
public async Task MyMethodAsync()
{
Task<int> longRunningTask = LongRunningOperationAsync();
// independent work which doesn't need the result of LongRunningOperationAsync can be done here
//and now we call await on the task
int result = await longRunningTask;
//use the result
Console.WriteLine(result);
}
public async Task<int> LongRunningOperationAsync() // assume we return an int from this long running operation
{
await Task.Delay(1000); // 1 second delay
return 1;
}
的大小需要len(group)
:
groups
或使用transform
:
db=table.groupby(['Type','Quarter'])
.filter(lambda group: len(group) > 3)
.groupby(['Type','Quarter'])["Price"]
.mean()