in [ ]data describe(out[ ] count mean - std min - - - - - max - - - - - - the ufunc np sign returns an array of and - depending on the sign of the values permutation and random sampling permuting (randomly reorderinga series or the rows in dataframe is easy to do using the numpy random permutation function calling permutation with the length of the axis you want to permute produces an array of integers indicating the new orderingin [ ]df dataframe(np arange( reshape( )in [ ]sampler np random permutation( in [ ]sampler out[ ]array([ ]that array can then be used in ix-based indexing or the take functionin [ ]df out[ ] in [ ]df take(samplerout[ ] to select random subset without replacementone way is to slice off the first elements of the array returned by permutationwhere is the desired subset size there are much more efficient sampling-without-replacement algorithmsbut this is an easy strategy that uses readily available toolsin [ ]df take(np random permutation(len(df))[: ]out[ ] to generate sample with replacementthe fastest way is to use np random randint to draw random integers data wranglingcleantransformmergereshape www it-ebooks info