小编Sri*_*uli的帖子

如何在 Neo4j 中使用 Cypher 查询进行分组和计算百分比

我在图形数据库、始发机场和目的地机场和承运人中创建了 3 个节点。它们通过名为“canceled_by”的属性相关联。

   MATCH (origin:origin_airport {name: row.ORIGIN}),
   (destination:dest_airport {name: row.DEST}),
   (carrier:Carrier {name: row.UNIQUE_CARRIER})
   CREATE (origin)-[:cancelled_by {cancellation: row.count}]->(carrier)
   CREATE (origin)-[:cancelled_by {cancellation: row.count}]->(destination)
   CREATE (origin)-[:operated_by {carrier: row.UNIQUE_CARRIER}]->(carrier)
Run Code Online (Sandbox Code Playgroud)

cancelled_by 保存特定载波被取消的次数值。我的输入文件将采用以下格式:

ORIGIN  UNIQUE_CARRIER  DEST    Cancelled
 ABE    DL                ATL    1
 ABE    EV                ATL    1
 ABE    EV                DTW    3
 ABE    EV                ORD    3
 ABQ    DL                DFW    2
 ABQ    B6                JFK    2
Run Code Online (Sandbox Code Playgroud)

这里我需要计算每个承运人的取消百分比。我期待的结果如下:

UNIQUE_CARRIER  DEST    Percentage_Cancelled
    DL                   25%
    EV                   58.33%
    B6                   16.66%

Example: Total number of cancellation = 12
No of cancellation for DL = 3
Percentage …
Run Code Online (Sandbox Code Playgroud)

r neo4j cypher

3
推荐指数
1
解决办法
2310
查看次数

标签 统计

cypher ×1

neo4j ×1

r ×1