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
1 answer

vectorised percentiles in pd.NamedAgg

I am having trouble applying numpy methods that require multiple input parameters with the pd.NamedAgg() methodology in pandas 0.25.1. Toy example: ## make df animals = pd.DataFrame({'kind': ['cat', 'dog', 'cat', 'dog'], …
Mark_Anderson
  • 1,229
  • 1
  • 12
  • 34
2
votes
3 answers

Aggregate rows with specific shared value

I want to aggregate my data as follows: Aggregate only for successive rows where status = 0 Keep age and sum up points Example data: da <- data.frame(userid = c(1,1,1,1,2,2,2,2), status = c(0,0,0,1,1,1,0,0), age = c(10,10,10,11,15,16,16,16),…
Scijens
  • 541
  • 2
  • 11
2
votes
2 answers

mongoDb:Cannot find index to verify that join fields will be unique

Hey I need to merge my two collections,but mongo retuns "Cannot find index to verify that join fields will be unique" 1.create unique index 2.remove whenMatched/whenNotMatched db.getCollection("GeoLite2-City-Blocks-IPv4").aggregate([ …
MikyChow
  • 25
  • 1
  • 6
2
votes
1 answer

Filter multiple occurrences based on group

I have a dataset like mentioned below: df=data.frame(Supplier_id=c("1","2","7","7","7","4","5","8","12","7"),…
hk2
  • 487
  • 3
  • 15
2
votes
1 answer

Django format DecimalField in query / annotation

Is it possible to format a DecimalField in an annotation similar to intcomma template tag? class Product(models.Model): plu = models.CharField(max_length=8) description = models.CharField(max_length=255) price =…
bdoubleu
  • 5,568
  • 2
  • 20
  • 53
2
votes
5 answers

Aggregate is deleting rows of the data

I'm new with R and I have tried a lot to solve this problem, if anyone could help me I'd be very grateful! This is my problem: I have to work with timeseries of a product that are separated by year, type (import or export from the country) and the…
importm
  • 305
  • 2
  • 10
2
votes
4 answers

Starting from a column type, how to find supported aggregations in Postgres?

I'm trying to figure out from a column type, which aggregates the data type supports. There's a lot of variety amongst types, just a sample below (some of these support more aggregates, of course): uuid count() text count(), min(),…
Morris de Oryx
  • 1,857
  • 10
  • 28
2
votes
1 answer

How do I map relations in an eventstore used in an eventsourced architecture?

I am trying to wrap my head around structuring relationships in an eventstore. I am all new at eventsourcing so please bear with me. :-) How should relationships be mapped in an eventstore? Can you please give me some recommendations? Imagine, I…
2
votes
1 answer

Why does aggregate NOT ignore NA values as per documentation?

Suppose I have the following data.frame: v <- data.frame(user=c("tom", "tom", "joe", "joe", "pat"), grade=c(70, NA, 80, 90, 100), stringsAsFactors = F) v user grade 1 tom 70 2 tom NA 3 joe 80 4 joe 90 5 pat 100 Suppose I would…
Denis
  • 11,796
  • 16
  • 88
  • 150
2
votes
2 answers

MongoDB collection update with $set and aggregate

I need to change the type of timestamp_ms filed from string to double and create FixedDate field which is based on this new timestamp_ms field. Than, change timestamp info into ISO date in NewDate field. I used this code: collection.update({ …
eabanoz
  • 251
  • 3
  • 17
2
votes
1 answer

How to use "Named aggregation"

I want to apply two different aggregates on the same column in a pandas DataFrameGroupBy and have the new columns be named. I've tried using what is shown here in the…
Levi Baguley
  • 646
  • 1
  • 11
  • 18
2
votes
3 answers

Return date range by group

I want to group by color and calculate the date range for that color. I have tried group_by(), summarize() and aggregate(). #Data: df1 <- as.Date(c('Jul 1', 'Jun 26', 'July 5', 'July 15'), format = '%B %d') df2 <- c("red", "blue", "red",…
Luke Holcomb
  • 165
  • 1
  • 8
2
votes
2 answers

Stored procedure to select values in table1, Group By, Sum, then insert those values into table2

I need a stored procedure to select rows from one table, do a Group By, Sum, and then insert the results into another table with their values. I guess I'll have to do a merge when rfds_processing_id (similar to an order number) matches existing…
hayes
  • 59
  • 6
2
votes
0 answers

How to get $graphLookup output generates hierarchy as nested array?

I want unspecified number of nested arrays output from graph lookup aggregation. I have data collection: [ { _id: 1, name: 'AA' }, { _id: 2, name: 'BB', parent: 1, ancestors: [1] }, { _id: 3, name: 'CC' }, { _id: 4,…
setha va
  • 51
  • 1
  • 1
  • 3
2
votes
2 answers

Aggregate by customized row breaks

I would take to take the mean of the columns by a certain break of the rows. For instance: set.seed(0) dt = data.frame(cbind(rnorm(10, 0, 1), rnorm(10, 0, 2), rnorm(10, 0, 3))) breaks = c(0,1,2,4,8,Inf) The only solution I can think of is manually…
Rachel Zhang
  • 562
  • 6
  • 20