What is the meaning of numpy reduceat() in python? -



What is the meaning of numpy reduceat() in python? -

i new in python , read @ moment tutorial.

i confused reduceat() function.

i saw example:

np.add.reduceat([0,1,2,3,4,5,6,7],[0,4,1,5,2,6,3,7])[::2]

and result is:

array([ 6, 10, 14, 18])

how come out? can 1 explain me?

it sort of rolling apply, see:

in [59]: np.add.reduceat([0,1,2,3,4,5,6,7],[0,4]) out[59]: array([ 6, 22]) in [65]: np.add.reduceat([0,1,2,3,4,5,6,7],[4,1]) out[65]: array([ 4, 28]) in [66]: np.add.reduceat([0,1,2,3,4,5,6,7],[1,5]) out[66]: array([10, 18]) in [64]: np.add.reduceat([0,1,2,3,4,5,6,7],[5,2]) out[64]: array([ 5, 27]) in [61]: np.add.reduceat([0,1,2,3,4,5,6,7],[2,6]) out[61]: array([14, 13]) in [67]: np.add.reduceat([0,1,2,3,4,5,6,7],[6,3]) out[67]: array([ 6, 25]) in [62]: np.add.reduceat([0,1,2,3,4,5,6,7],[3,7]) out[62]: array([18, 7])

if want 1st value, can done in 1 shot:

in [63]: np.add.reduceat([0,1,2,3,4,5,6,7],[0,4,1,5,2,6,3,7]) out[63]: array([ 6, 4, 10, 5, 14, 6, 18, 7])

python numpy

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -