Quantcast
Viewing all articles
Browse latest Browse all 41

Answer by double0darbo for How can I partition (split up, divide) a list based on a condition?

I turned to numpy to solve this to limit lines and make into a simple function.

I was able to get a conditional met, separating a list into two, using np.where to separate out a list. This works for numeric, but this could be expanded using strings and lists I believe.

Here it is...

from numpy import where as wh, array as arrmidz = lambda a, mid: (a[wh(a > mid)], a[wh((a =< mid))])p_ = arr([i for i in [75, 50, 403, 453, 0, 25, 428] if i])high,low = midz(p_, p_.mean())

Viewing all articles
Browse latest Browse all 41

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>