Questions tagged [aggregate]

Aggregate refers to the process of summarizing grouped data, commonly used in Statistics.

Aggregate refers to the process of summarizing grouped data, commonly used in Statistics. Typically this involves replacing groups of data with single values (e.g. sum, mean, standard deviation, etc.). In SQL databases and data manipulation libraries such as in , this is accomplished with the use of GROUP BY and aggregate functions.

Documentation:

8256 questions
2
votes
2 answers

group_by() summarise() and weights percentages - R

Let's suppose that a company has 3 Bosses and 20 Employees, where each Employee has done n_Projects with an overall Performance in percentage: > df <- data.frame(Boss = sample(1:3, 20, replace=TRUE), Employee = sample(1:20,20), …
Chris
  • 2,019
  • 5
  • 22
  • 67
2
votes
2 answers

aggregation with indices not present in dataframe

df = pd.DataFrame({'x':[1,2,3,4,5,6],'y':[7,8,9,10,11,12],'z':['a','a','a','b','b','b']}) i = pd.Index([0,3,5,10,20]) The indices in i are from a larger dataframe, and df is a subset of that larger dataframe. So there will be indices in i that will…
HappyPy
  • 9,839
  • 13
  • 46
  • 68
2
votes
2 answers

How to select rows with max values of 2 columns

I have a table mysql like this : CREATE TABLE prelevement ( line int, facture varchar(30), date_op varchar(30), code_op varchar(30) ); insert into prelevement (line,facture,date_op,code_op) values…
Sophia
  • 21
  • 1
2
votes
1 answer

MongoDB aggregate field in array of objects

I'm trying to solve a problem for some time now but with no luck, unfortunately. So I'm refactoring some old code (which used the all known get each doc query and for loop over it) and I'm trying to aggregate the results to remove the thousands of…
GrimR1P
  • 152
  • 1
  • 12
2
votes
1 answer

A problem with understanding aggregates and aggregate roots in Domain Driven Design (DDD)

I've stumbled upon a problem: "I can't split my domain models into aggregate roots". I'm a junior developer and novice at DDD. I really want to understand it, but sometimes it's really confusing. From this point I want to describe my domain…
2
votes
0 answers

MongoDB aggregate count with facet is too much slow

My case is very similar a this (MongoDB aggregate count is too much slow) case, I have a 40.000 docs and this aggregate takes 8 seconds to give me the total count (40.000) showing only the 10 docs (limit). P.S. If I run customers.find().count(), it…
Biruel Rick
  • 776
  • 1
  • 8
  • 17
2
votes
1 answer

MongoDB aggregate from adjustable foreign collections

My documents in the orders collection has _client key, which is an ObjectId references to another entity in another collection. The collection could be organization and could be users - I mean - it's variable collection. I want to tell Mongo to…
Raz Buchnik
  • 7,753
  • 14
  • 53
  • 96
2
votes
1 answer

Pandas df grouby certain match on different column

I want to aggregate a pandas df column by 2 criteria. 1) First I want to groupby col1 2) I want the mean of col3 only if col2 has minimum one row of matching 0 AND minimum one row what matches 1. I tried some combination of this but this does not…
Geveze
  • 393
  • 3
  • 12
2
votes
1 answer

Aggregating different sets of columns with different functions after groupby in Pandas

I want to be able to pass the names of lists containing column names in a dataframe and apply after groupby different aggregating functions to each set. So a naive and unsuccessful attempt was the following: import pandas as pd import seaborn as…
user8270077
  • 4,621
  • 17
  • 75
  • 140
2
votes
1 answer

Sum values according to specific condition in R

i have a df structured like this: Ateco. Numb. Reg 10 223 A 11 332 A 12 343 A 10 223 B 11 332 B 12 343 B 29 414 B 30 434 B 31 444 B 32 464 B and I want to obtain…
Silvia
  • 405
  • 4
  • 17
2
votes
2 answers

MongoDB aggregate array documents

I have a MongoDB collection containing elements like this: { "name": "test", "instances": [ { "year": 2015 }, { "year": 2016 }, ] } How can I get the minimum and maximum value for…
LukeLR
  • 1,129
  • 1
  • 14
  • 27
2
votes
1 answer

Collapse rows from 0 to 0

For a dataset like this Incident.ID.. date product INCFI0000029582 2014-09-25 08:39:45 foo INCFI0000029582 2014-09-25 08:39:48 bar INCFI0000029582 2014-09-25 08:40:44 foo …
King Frazier
  • 243
  • 3
  • 14
2
votes
0 answers

I am trying to get seasonal melt information from a daily data. cannot aggregate by season

I am trying to create a new table from an existing one. I've selected the columns I need, Month, Year, and Temperature. There are is one row for each day. I've managed to add another column, with a 1 or 0 for each day above freezing. I would now…
S.OBrien
  • 21
  • 1
2
votes
1 answer

graphql query return object with null id

Graphql return Oject with null id. with mongodb. It looks strange to me. If I delete new GraphQLNonNull() on MailType id, It works with id: null, another fields working fine. const MailType = new GraphQLObjectType({ name: 'Mail', fields: ()…
yusung lee
  • 236
  • 1
  • 12
2
votes
2 answers

How to group by a column and do normalization?

Suppose I have a dateframe like this: A B C 0 foo one 1 1 bar one 2 2 foo two 1 3 bar three 2 4 foo two 3 5 bar two 5 6 foo one 2 7 foo three 5 8 bar one 4 I…
ZHICHEN GUO
  • 100
  • 5