tagged [aggregate]

Mean per group in a data.frame

Mean per group in a data.frame I have a `data.frame` and I need to calculate the mean per group (i.e. per `Month`, below). ``` Name Month Rate1 Rate2 Aira 1 12 23 Aira 2 18 73 Aira...

4 May at 13:10

Performing a query on a result from another query?

Performing a query on a result from another query? I have a the query: Which returns something l

4 Jun at 09:25

SELECT list is not in GROUP BY clause and contains nonaggregated column

SELECT list is not in GROUP BY clause and contains nonaggregated column Receiving the following error: When running the following query: ``` select country

7 Dec at 18:53

SQL JOIN, GROUP BY on three tables to get totals

SQL JOIN, GROUP BY on three tables to get totals I've inherited the following DB design. Tables are: My query needs to return invoiceid, the invoice amount (in the invoices ta

24 Apr at 19:14

Aggregate multiple columns at once

Aggregate multiple columns at once I have a data-frame likeso: ``` x

30 Dec at 05:50

Using Enumerable.Aggregate(...) Method over an empty sequence

Using Enumerable.Aggregate(...) Method over an empty sequence I would like to use the method to concatenate a list of strings separated by a semicolon. Rather easy, isn't it? Considering the following...

15 Feb at 14:43

Aggregate or join strings in linq to sql query (SQL Server)

Aggregate or join strings in linq to sql query (SQL Server) Given a table like I want to produce a result like I tried something like ``` From C In Clients Group C By C.ID, C.City _ Into G = Group Sel...

6 Aug at 21:53

How do I Pandas group-by to get sum?

How do I Pandas group-by to get sum? I am using this dataframe: ``` Fruit Date Name Number Apples 10/6/2016 Bob 7 Apples 10/6/2016 Bob 8 Apples 10/6/2016 Mike 9 Apples 10/7/2016 Steve 10 Apples ...

Summarizing multiple columns with dplyr?

Summarizing multiple columns with dplyr? I'm struggling a bit with the dplyr-syntax. I have a data frame with different variables and one grouping variable. Now I want to calculate the mean for each c...

12 Feb at 03:3

LINQ aggregate and group by periods of time

LINQ aggregate and group by periods of time I'm trying to understand how LINQ can be used to group data by intervals of time; and then ideally aggregate each group. Finding numerous examples with expl...

13 Jan at 19:40

collapsing NULL values in Oracle query

collapsing NULL values in Oracle query I often write queries wherein I pivot data and end up with NULL values that I want to collapse. E.g. data like the following: I then do an outer query like so: `...

18 Nov at 20:12

Optimal way to concatenate/aggregate strings

Optimal way to concatenate/aggregate strings I'm finding a way to aggregate strings from different rows into a single row. I'm looking to do this in many different places, so having a function to faci...

Multiple aggregations of the same column using pandas GroupBy.agg()

Multiple aggregations of the same column using pandas GroupBy.agg() Is there a pandas built-in way to apply two different aggregating functions `f1, f2` to the same column `df["returns"]`, without hav...

SQL Server "cannot perform an aggregate function on an expression containing an aggregate or a subquery", but Sybase can

SQL Server "cannot perform an aggregate function on an expression containing an aggregate or a subquery", but Sybase can This issue has been discussed before, but none of the answers address my specif...

Pandas sum by groupby, but exclude certain columns

Pandas sum by groupby, but exclude certain columns What is the best way to do a groupby on a Pandas dataframe, but exclude some columns from that groupby? e.g. I have the following dataframe: ``` Code...

3 Mar at 02:46

How to do Linq aggregates when there might be an empty set?

How to do Linq aggregates when there might be an empty set? I have a Linq collection of `Things`, where `Thing` has an `Amount` (decimal) property. I'm trying to do an aggregate on this for a certain ...

12 Jan at 00:46

SQL user defined aggregate order of values preserved?

SQL user defined aggregate order of values preserved? Im using the code from [this MSDN page](http://msdn.microsoft.com/en-us/library/ms131056.aspx) to create a user defined aggregate to concatenate s...

How can I use LINQ and lambdas to perform a bitwise OR on a bit flag enumeration property of objects in a list?

How can I use LINQ and lambdas to perform a bitwise OR on a bit flag enumeration property of objects in a list? I have a collection of objects, and each object has a bit field enumeration property. Wh...

9 May at 23:53

Is it possible to use Linq to get a total count of items in a list of lists?

Is it possible to use Linq to get a total count of items in a list of lists? We have a simple structure which is just a list of lists, like so... I'm wondering if there's a simple way we can use linq ...

7 May at 21:45

Compute mean and standard deviation by group for multiple variables in a data.frame

Compute mean and standard deviation by group for multiple variables in a data.frame -- This question was originally titled > --- I'm just learning R and trying to find ways to apply it to help out oth...

4 May at 06:22

Pandas aggregate count distinct

Pandas aggregate count distinct Let's say I have a log of user activity and I want to generate a report of the total duration and the number of unique users per day. ``` import numpy as np import pand...

4 May at 07:19

Entity Framework with LINQ aggregate to concatenate string?

Entity Framework with LINQ aggregate to concatenate string? This is easy for me to perform in TSQL, but I'm just sitting here banging my head against the desk trying to get it to work in EF4! I have a...

18 Nov at 13:8

Reason for Column is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause

Reason for Column is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause I got an error - > Column 'Employee.EmpID' is invalid in the select l...

11 May at 22:29

C#: How to use the Enumerable.Aggregate method

C#: How to use the Enumerable.Aggregate method Lets say I have this amputated `Person` class: I can then group on `Age` and `Country` like this: ``` var groups = aListOfPeople.GroupBy(x => new { x

15 Dec at 12:34

Apply multiple functions to multiple groupby columns

Apply multiple functions to multiple groupby columns The [docs](http://pandas.pydata.org/pandas-docs/dev/groupby.html#applying-multiple-functions-at-once) show how to apply multiple functions on a gro...