grouping

How to create a new list item with FLOWR and XQuery?

我的梦境 提交于 2020-02-25 06:30:49
问题 I'm looking to select non-numerical data from an XML file towards shredding it into database columns, or at least an xmltable -like structure. This FLWOR gives a somewhat useful result: xquery version "3.0"; declare namespace office="urn:oasis:names:tc:opendocument:xmlns:text:1.0"; <ul> { for $foo in db:open("foo") return <li>{$foo//text()[not(matches(., '[0-9]'))]}</li> } </ul> However, it outputs all results into a single li tag, like: a b c d Preferred output would be of the form: a b Most

Filter points XY by distance with LINQ

喜夏-厌秋 提交于 2020-02-24 11:20:49
问题 I have a list of points XY and I want to group them by a given distance, let's say all the points that are at x distance between them should be grouped in different list. Basically if I have A=(0,0), B=(0,1), C=(0,2), I want to group all points that have a maxDistance of 1, in order to obtain :[[A,B],[C]] ; 回答1: I didn't really understand your question, so I'm not really sure how you want to do the grouping, but this might start you off in the right direction, at least. (Written in VB, but

How do I group items in an array by date?

梦想与她 提交于 2020-02-21 11:25:36
问题 Given the following array of objects: [ { "notes": "Game was played", "time": "2017-10-04T20:24:30+00:00", "sport": "hockey", "owner": "steve", "players": "10", "game_id": 1, }, { "notes": "Game was played", "time": "2017-10-04T12:35:30+00:00", "sport": "lacrosse", "owner": "steve", "players": "6", "game_id": 2, }, { "notes": "Game was played", "time": "2017-10-14T20:32:30+00:00", "sport": "hockey", "owner": "steve", "players": "4", "game_id": 3, }, { "notes": "Game was played", "time": "2017

How do I group items in an array by date?

限于喜欢 提交于 2020-02-21 11:23:22
问题 Given the following array of objects: [ { "notes": "Game was played", "time": "2017-10-04T20:24:30+00:00", "sport": "hockey", "owner": "steve", "players": "10", "game_id": 1, }, { "notes": "Game was played", "time": "2017-10-04T12:35:30+00:00", "sport": "lacrosse", "owner": "steve", "players": "6", "game_id": 2, }, { "notes": "Game was played", "time": "2017-10-14T20:32:30+00:00", "sport": "hockey", "owner": "steve", "players": "4", "game_id": 3, }, { "notes": "Game was played", "time": "2017

Group and sum list of dictionaries by parameter

ε祈祈猫儿з 提交于 2020-02-21 06:10:09
问题 I have a list of dictionaries of my products (drinks, food, etc), some of the products may be added several times. I need to group my products by product_id parameter and sum product_cost and product_quantity of each group to get the total product price. I'm a newbie in python, understand how to group list of dictionaries but can't figure out how to sum some parameter values. "products_list": [ { "product_cost": 25, "product_id": 1, "product_name": "Coca-cola", "product_quantity": 14, }, {

Group and sum list of dictionaries by parameter

自古美人都是妖i 提交于 2020-02-21 06:05:17
问题 I have a list of dictionaries of my products (drinks, food, etc), some of the products may be added several times. I need to group my products by product_id parameter and sum product_cost and product_quantity of each group to get the total product price. I'm a newbie in python, understand how to group list of dictionaries but can't figure out how to sum some parameter values. "products_list": [ { "product_cost": 25, "product_id": 1, "product_name": "Coca-cola", "product_quantity": 14, }, {

How do I visualize n-dimensional features?

感情迁移 提交于 2020-02-05 07:58:12
问题 I have two matrices A and B . The size of A is 200*1000 double (here: 1000 represents 1000 different features). Matrix A belongs to group 1, where I use ones(200,1) as the label vector. The size of B is also 200*1000 double (here: 1000 also represents 1000 different features). Matrix B belongs to group 2, where I use -1*ones(200,1) as the label vector. My question is how do I visualize matrices A and B so that I can clearly distinguish them based on the given groups? 回答1: I'm assuming each

Group strings by longest common starting substring

佐手、 提交于 2020-02-02 12:51:16
问题 Here's the problem. Say I have these strings: apple ipad mini 32gb apple ipad mini 64gb apple ipad air 64gb apple ipad air 32gb panasonic gh4 samsung s2 galaxy samsung s2 galaxy red samsung s3 galaxy I want these strings to be grouped like this: apple ipad mini: [apple ipad mini 32gb, apple ipad mini 64gb] apple ipad air: [apple ipad air 64gb, apple ipad 32gb] panasonic gh4: [panasonic gh4] samsung s2 galaxy: [samsung s2 galaxy, samsung s2 galaxy red] samsung s3 galaxy The point is to

Grouping pyspark dataframe by intersection [duplicate]

亡梦爱人 提交于 2020-01-30 10:59:52
问题 This question already has an answer here : How to group by common element in array? (1 answer) Closed 7 months ago . I need to group PySpark dataframe by intersection of arrays in column. For example from dataframe like this: v1 | [1, 2, 3] v2 | [4, 5] v3 | [1, 7] result should be: [v1, v3] | [1, 2, 3, 7] [v2] | [4, 5] Because rows 1st and 3rd have value 1 in common. Is there a method like group by when intersection? Thank you in advance for ideas and suggestions how to solve this. 回答1: from

XSLT unable to group/sort nodes based on value

浪尽此生 提交于 2020-01-30 08:24:05
问题 I'm trying to transform this xml. However I'm having formatting issues. Could someone please guide me to solve this problem. Thanks in advance <?xml version="1.0" encoding="windows-1252"?> <XML> <Attributes> <Attribute> <id>5</id> <Name>Buyer ID</Name> <Type>common</Type> <Value>Lee</Value> </Attribute> <Attribute> <id>331</id> <Name>Enviornment</Name> <Type>common</Type> <Value>Development</Value> </Attribute> <Attribute> <id>79</id> <Name>Retail</Name> <Type>common</Type> <Value></Value> <