Apoc.agg.statistics() is not working?

neo4j : several recent versions, apoc: several recent versions

I tried it in https://guides.neo4j.com/4.0-intro-graph-algos-exercises/LabelPropagation.html
UNWIND ['distance','inverse_distance'] as property
MATCH (:Place)-[r:EROAD]->(:Place)
RETURN property, apoc.agg.statistics(r[property]) as stats

It returns this error:
Neo.ClientError.Procedure.ProcedureCallFailed
Failed to invoke function apoc.agg.statistics: Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1

It seems like the solution to the exercise left out the percentiles parameter from the apoc.agg.statistics() function. The correct syntax should be

UNWIND ['distance','inverse_distance'] as property
MATCH (:Place)-[r:EROAD]->(:Place)
RETURN property, apoc.agg.statistics(r[property], [0.5,0.75,0.9,0.95,0.99]) as stats

Hope this helps!

-Jorge

2 Likes

Yes, it works now!!
Thank your for the help.

Hope God bless you.

1 Like