#NEWLINE# def create_panels_join( cls , panels ) : #NEWLINE# #INDENT# " given an array of panels's, create a single panel " #NEWLINE# panels = [ a for a in panels if ( a is not None ) ] #NEWLINE# if ( len ( panels ) == 0 ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( panels ) == 1 ) : #NEWLINE# #INDENT# return panels [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( len ( panels ) == 2 ) and ( panels [ 0 ] == panels [ 1 ] ) ) : #NEWLINE# #INDENT# return panels [ 0 ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# d = dict ( ) #NEWLINE# ( minor , major , items ) = ( set ( ) , set ( ) , set ( ) ) #NEWLINE# for panel in panels : #NEWLINE# #INDENT# items . update ( panel . items ) #NEWLINE# major . update ( panel . major_axis ) #NEWLINE# minor . update ( panel . minor_axis ) #NEWLINE# values = panel . values #NEWLINE# for ( item , item_index ) in panel . items . indexMap . items ( ) : #NEWLINE# #INDENT# for ( minor_i , minor_index ) in panel . minor_axis . indexMap . items ( ) : #NEWLINE# #INDENT# for ( major_i , major_index ) in panel . major_axis . indexMap . items ( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# d [ ( minor_i , major_i , item ) ] = values [ ( item_index , major_index , minor_index ) ] #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# minor = sorted ( list ( minor ) ) #NEWLINE# major = sorted ( list ( major ) ) #NEWLINE# items = sorted ( list ( items ) ) #NEWLINE# data = np . dstack ( [ np . asarray ( [ np . asarray ( [ d . get ( ( minor_i , major_i , item ) , np . nan ) for item in items ] ) for major_i in major ] ) . transpose ( ) for minor_i in minor ] ) #NEWLINE# return Panel ( data , items , major , minor )