#NEWLINE# def summary( self , stats = 'basic' , columns = 'all' , orientation = 'auto' ) : #NEWLINE# #INDENT# "\n        Return a summary of descriptive statistics.\n\n        Parameters\n        -----------\n        stats: list or str\n            The desired statistics, Accepts 'basic' or 'all' or a list.\n               'basic' = ('obs', 'mean', 'std', 'min', 'max')\n               'all' = ('obs', 'mean', 'std', 'min', 'max', 'ptp', 'var',\n                        'mode', 'meadian', 'skew', 'uss', 'kurtosis',\n                        'percentiles')\n        columns : list or str\n          The columns/variables to report the statistics, default is 'all'\n          If an object with named columns is given, you may specify the\n          column names. For example\n        " #NEWLINE# if ( self . _arraytype == None ) : #NEWLINE# #INDENT# self . _array_typer ( ) #NEWLINE# #UNINDENT# if ( stats == 'basic' ) : #NEWLINE# #INDENT# stats = ( 'obs' , 'mean' , 'std' , 'min' , 'max' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( stats == 'all' ) : #NEWLINE# #INDENT# stats = [ 'obs' , 'mean' , 'std' , 'min' , 'max' , 'ptp' , 'var' , 'mode_val' , 'mode_bin' , 'median' , 'uss' , 'skew' , 'kurtosis' , 'percentiles' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# for astat in stats : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# import scipy.stats #NEWLINE# def _fun( per ) : #NEWLINE# #INDENT# return ( lambda x : scipy . stats . scoreatpercentile ( x , per ) ) #NEWLINE# #UNINDENT# perdict = dict ( ( ( ( 'perc_%02d' % per ) , [ _fun ( per ) , None , None ] ) for per in ( 1 , 5 , 10 , 25 , 50 , 75 , 90 , 95 , 99 ) ) ) #NEWLINE# if ( 'percentiles' in stats ) : #NEWLINE# #INDENT# self . univariate . update ( perdict ) #NEWLINE# idx = stats . index ( 'percentiles' ) #NEWLINE# stats [ idx : ( idx + 1 ) ] = sorted ( iterkeys ( perdict ) ) #NEWLINE# #UNINDENT# if any ( [ aitem [ 1 ] for aitem in iteritems ( self . univariate ) if ( aitem [ 0 ] in stats ) ] ) : #NEWLINE# #INDENT# if ( columns == 'all' ) : #NEWLINE# #INDENT# self . _columns_list = [ ] #NEWLINE# if ( self . _arraytype == 'sctruct' ) : #NEWLINE# #INDENT# self . _columns_list = self . dataset . dtype . names #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _columns_list = lrange ( self . dataset . shape [ 1 ] ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . _columns_list = columns #NEWLINE# if ( self . _arraytype == 'sctruct' ) : #NEWLINE# #INDENT# for col in self . _columns_list : #NEWLINE# #INDENT# assert ( col in self . dataset . dtype . names ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# assert ( self . _is_dtype_like ( self . dataset ) == 'number' ) #NEWLINE# #UNINDENT# #UNINDENT# columstypes = self . dataset . dtype #NEWLINE# for astat in stats : #NEWLINE# #INDENT# calc = self . univariate [ astat ] #NEWLINE# if ( self . _arraytype == 'sctruct' ) : #NEWLINE# #INDENT# calc [ 1 ] = self . _columns_list #NEWLINE# calc [ 2 ] = [ calc [ 0 ] ( stats . dataset [ col ] ) for col in self . _columns_list if ( self . _is_dtype_like ( col ) == 'number' ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# calc [ 1 ] = [ ( 'Col ' + str ( col ) ) for col in self . _columns_list ] #NEWLINE# calc [ 2 ] = [ calc [ 0 ] ( self . dataset [ : , col ] ) for col in self . _columns_list ] #NEWLINE# #UNINDENT# #UNINDENT# return self . print_summary ( stats , orientation = orientation ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return self . print_summary ( stats , orientation = orientation )