array( ] to then get labeling of which interval each data point belongs to (where would mean the bucket [ ))we can simply use searchsortedin [ ]labels bins searchsorted(datain [ ]labels out[ ]array([ ]thiscombined with pandas' groupbycan be used to easily bin datain [ ]series(datagroupby(labelsmean(out[ ] note that numpy actually has function digitize that computes this bin labelingin [ ]np digitize(databinsout[ ]array([ ]numpy matrix class compared with other languages for matrix operations and linear algebralike matlabjuliaand gaussnumpy' linear algebra syntax can often be quite verbose one reason is that matrix multiplication requires using numpy dot also numpy' indexing semantics are differentwhich makes porting code to python less straightforward at times selecting single row ( [ :]or column ( [: ]from array yields array compared with array as insaymatlab in [ ] np array([ [- - ] ] ] ]]in [ ] [: one-dimensional out[ ]array( - ]in [ ] [:: two-dimensional by slicing numpy matrix class www it-ebooks info