Closed TuSKan closed 2 years ago
$.peoples.birthDate
is a list, so dateTime won't work. Maybe I should extend map() to accept parameters. I will think about it.
Greetings, Adrian Kalbarczyk
ᐧ
On Wed, Dec 5, 2018 at 3:31 AM Rener Castro notifications@github.com wrote:
Hello, In my problem I need to compute the average age of a sub population.
{ "peoples":[ { "name":"Kelly Robertson", "birthDate":"1980-05-11 04:22:33" }, { "name":"Trevin Haley", "birthDate":"1985-09-12 12:03:10" } ] }
It works for
avg(age(dateTime($.peoples.birthDate.*[1],'%Y-%m-%d %H:%M:%S')))
but not for all elements
avg(age(dateTime($.peoples.birthDate,'%Y-%m-%d %H:%M:%S')))
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/adriank/ObjectPath/issues/81, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKycv3W_m2cH8hnF5yvgWkXGmGPbRIBks5u1y_ygaJpZM4ZB4zN .
It could be this way ?
avg(age(map(dateTime, $.peoples.birthDate, args = '%Y-%m-%d %H:%M:%S')))
A map function could be very helpful. Could implement map as:
def map(f, array, args = None):
return map(lambda x: f(x, args), array)
Hello, In my problem I need to compute the average age of a sub population.
It works for
but not for all elements