#NEWLINE# def datatable( x , data , ax , by = None , probs = None ) : #NEWLINE# #INDENT# '\n    Create a datatable on a provided axes\n    ' #NEWLINE# headers = [ 'Mean' , 'Stdev' , 'Min' , '05%' , '50%' , '95%' , 'Max' , 'N' ] #NEWLINE# if ( probs == 'bayes' ) : #NEWLINE# #INDENT# headers = [ 'Mean' , 'Stdev' , 'Min' , '2.5%' , '50%' , '97.5%' , 'Max' , 'N' ] #NEWLINE# #UNINDENT# stats = common . stats . array_stats ( x , data = data , by = by ) #NEWLINE# groups = [ ] #NEWLINE# values = [ ] #NEWLINE# for ( group , tup ) in stats . items ( ) : #NEWLINE# #INDENT# groups . append ( group ) #NEWLINE# if ( probs == 'bayes' ) : #NEWLINE# #INDENT# array = [ round ( tup [ val ] , 3 ) for val in ( 0 , 1 , 2 , 3 , 6 , 9 , 10 , 11 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# array = [ round ( tup [ val ] , 3 ) for val in ( 0 , 1 , 2 , 4 , 6 , 8 , 10 , 11 ) ] #NEWLINE# #UNINDENT# values . append ( array ) #NEWLINE# #UNINDENT# tab = ax . table ( cellText = values , rowLabels = groups , colLabels = headers , loc = 'upper left' , transform = ax . transAxes ) #NEWLINE# tab . set_fontsize ( 8 ) #NEWLINE# ax . set_axis_bgcolor ( 'white' ) #NEWLINE# ax . grid ( b = False ) #NEWLINE# ax . set_xticklabels ( [ ] ) #NEWLINE# ax . set_yticklabels ( [ ] ) #NEWLINE# ax . set_ylim ( [ 0 , 1 ] ) #NEWLINE# return ax