other:python:misc_by_jyp
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
other:python:misc_by_jyp [2022/02/21 16:15] – [numpy related stuff] jypeter | other:python:misc_by_jyp [2022/02/21 17:31] – [numpy related stuff] Added ufuncs jypeter | ||
---|---|---|---|
Line 253: | Line 253: | ||
15.5 | 15.5 | ||
>>> | >>> | ||
- | 15.5</ | + | 15.5 |
+ | |||
+ | # Compute the sum of the elements of ' | ||
+ | # AND keep (accumulate) the intermediate results | ||
+ | >>> | ||
+ | array([3, 3, 4]) | ||
+ | >>> | ||
+ | array([ 3, 6, 10]) | ||
+ | |||
+ | # The accumulated values can be used as indices to separate the different groups of sorted values! | ||
+ | >>> | ||
+ | array([1. , 1. , 1. , 1.5, 1.5, 1.5, 2. , 2. , 2. , 2. ]) | ||
+ | >>> | ||
+ | array([1., 1., 1.]) | ||
+ | >>> | ||
+ | array([1.5, 1.5, 1.5]) | ||
+ | >>> | ||
+ | array([2., 2., 2., 2.]) | ||
+ | |||
+ | # Compute the sum of each equal-value group | ||
+ | >>> | ||
+ | (3.0, 4.5, 8.0)</ | ||
/* | /* |
other/python/misc_by_jyp.txt · Last modified: 2024/11/04 15:01 by jypeter