aggregation

Elasticsearch aggregation. Order by nested bucket doc_count

不羁岁月 提交于 2019-12-02 05:04:54
What I want to achieve is aggregation by unique pairs (city, STATE). As per Elasticsearch documentation The terms aggregation does not support collecting terms from multiple fields in the same document . Thus I created a nested agg like this: { "size": 0, "aggs": { "cities": { "terms": { "field": "address.city", "size": 12 }, "aggs": { "states": { "terms": { "field": "address.stateOrProvince" }, "aggs": { "topCity": { "top_hits": { "size": 1, "sort": [ { "price.value": { "order": "desc" }}]}}}}}}}} As a result of this aggregation I get response like this: { "aggregations": { "cities": {

Pandas: Calculate mean leaving out own row's value

大憨熊 提交于 2019-12-02 04:18:30
I want to calculate means by group, leaving out the value of the row itself. import pandas as pd d = {'col1': ["a", "a", "b", "a", "b", "a"], 'col2': [0, 4, 3, -5, 3, 4]} df = pd.DataFrame(data=d) I know how to return means by group: df.groupby('col1').agg({'col2': 'mean'}) Which returns: Out[247]: col1 col2 1 a 4 3 a -5 5 a 4 But what I want is mean by group, leaving out the row's value. E.g. for the first row: df.query('col1 == "a"')[1:4].mean() which returns: Out[251]: col2 1.0 dtype: float64 Edit: Expected output is a dataframe of the same format as df above, with a column mean_excl_own

Aggregating over _field_names in elasticsearch 5

我只是一个虾纸丫 提交于 2019-12-02 03:47:43
I'm trying to aggregate over field names in ES 5 as described in Elasticsearch aggregation on distinct keys But the solution described there is not working anymore. My goal is to get the keys across all the documents. Mapping is the default one. Data: PUT products/product/1 { "param": { "field1": "data", "field2": "data2" } } Query: GET _search { "aggs": { "params": { "terms": { "field": "_field_names", "include" : "param.*", "size": 0 } } } } I get following error: Fielddata is not supported on field [_field_names] of type [_field_names] After looking around it seems the only way in ES > 5.X

SAPUI5 routing throws error “Control (ID of an App control) does not has an aggregation called pages”

主宰稳场 提交于 2019-12-02 03:09:19
What I have in my Component.js are these routes: routes: [ { pattern: "", name: "menu", view: "Menu", targetAggregation: "pages", targetControl: "idAppControl", subroutes: [ { pattern: "Reports", name: "reports", view: "SplitContainer", targetAggregation: "pages", targetControl: "idAppControl", clearTarget: true } ] } ] When I try to access the subroute (URL/#/Reports) the application throws (Chrome): Control idAppControl does not has an aggregation called pages - This is confusing due to the fact, that "idAppControl" is an App and therefor HAS an aggregation pages. Also, the first "main"

Conditional calculating the numbers of values in column with R

安稳与你 提交于 2019-12-02 01:38:16
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 5 years ago . I have two vectors: x <- c(1,1,1,1,1, 2,2,2,3,3, 3,3,3,4,4, 5,5,5,5,5 ) y <- c(2,2,1,3,2, 1,4,2,2,NA, 3,3,3,4,NA, 1,4,4,2,NA) This question (Conditional calculating the numbers of values in column with R, part2) discussed how to find the number of values in w (don't count NA ) for each x (from 1–5) and for each y (from 1–4). Let's split X by groups: if x<=2 , group I ; if 2<x<

Conditional calculating the numbers of values in column with R

别说谁变了你拦得住时间么 提交于 2019-12-02 01:10:23
I have two vectors: x <- c(1,1,1,1,1, 2,2,2,3,3, 3,3,3,4,4, 5,5,5,5,5 ) y <- c(2,2,1,3,2, 1,4,2,2,NA, 3,3,3,4,NA, 1,4,4,2,NA) This question ( Conditional calculating the numbers of values in column with R, part2 ) discussed how to find the number of values in w (don't count NA ) for each x (from 1–5) and for each y (from 1–4). Let's split X by groups: if x<=2 , group I ; if 2<x<=3 , group II ; and if 3<X<=5 , group III . I need to find the number of different values in x by groups and by every value of y . I also need to find the mean of those values in x by the same groups. The output should

Aggregate a Dask dataframe and produce a dataframe of aggregates

拥有回忆 提交于 2019-12-01 20:08:51
问题 I have a Dask dataframe that looks like this: url referrer session_id ts customer url1 ref1 xxx 2017-09-15 00:00:00 a.com url2 ref2 yyy 2017-09-15 00:00:00 a.com url2 ref3 yyy 2017-09-15 00:00:00 a.com url1 ref1 xxx 2017-09-15 01:00:00 a.com url2 ref2 yyy 2017-09-15 01:00:00 a.com I want to group the data on url and timestamp, aggregate column values and produce a dataframe that would look like this instead: customer url ts page_views visitors referrers a.com url1 2017-09-15 00:00:00 1 1

Aggregate a Dask dataframe and produce a dataframe of aggregates

空扰寡人 提交于 2019-12-01 18:40:38
I have a Dask dataframe that looks like this: url referrer session_id ts customer url1 ref1 xxx 2017-09-15 00:00:00 a.com url2 ref2 yyy 2017-09-15 00:00:00 a.com url2 ref3 yyy 2017-09-15 00:00:00 a.com url1 ref1 xxx 2017-09-15 01:00:00 a.com url2 ref2 yyy 2017-09-15 01:00:00 a.com I want to group the data on url and timestamp, aggregate column values and produce a dataframe that would look like this instead: customer url ts page_views visitors referrers a.com url1 2017-09-15 00:00:00 1 1 [ref1] a.com url2 2017-09-15 00:00:00 2 2 [ref2, ref3] In Spark SQL, I can do this as follows: select

aggregate values from several fields into one

吃可爱长大的小学妹 提交于 2019-12-01 12:15:38
I have the following data frame in R: objects categories A 162 B 162 B 190 C 123 C 162 C 185 C 190 C 82 C 191 D 185 As you see there are objects and the categories they belong to. I would like to sum up the categories of each object in comma separated list to get a data frame which would look like this: objects categories A 162 B 162, 190 C 123, 162, 185, 190, 82, 191 D 185 How could I do this? This can be done with any of the aggregation tools of your choice, I'll show an example using plyr package and paste() function. This assumes your data is named x : library(plyr) ddply(x, .(objects),

Is this an aggregation?

我怕爱的太早我们不能终老 提交于 2019-12-01 11:24:27
问题 I have the following code public static void main(String[] args) { Engine engine = new Engine("This Engine!"); Car b = new Car(engine); b = null; } Is this an aggregation? I always think that an aggregation is when something can still "live" even if the other class is "destroyed"... so for example Car and Engine. if I delete the Car instance, the Engine can still live. Is this correct? 回答1: First, I would say that your code would look better when you do Car b = new Car(); b.setEngine(engine);