#NEWLINE# def dot( self , other ) : #NEWLINE# #INDENT# '\n        Matrix multiplication with DataFrame or inner-product with Series\n        objects\n\n        Parameters\n        ----------\n        other : Series or DataFrame\n\n        Returns\n        -------\n        dot_product : scalar or Series\n        ' #NEWLINE# from pandas.core.frame import DataFrame #NEWLINE# if isinstance ( other , ( Series , DataFrame ) ) : #NEWLINE# #INDENT# common = self . index . union ( other . index ) #NEWLINE# if ( ( len ( common ) > len ( self . index ) ) or ( len ( common ) > len ( other . index ) ) ) : #NEWLINE# #INDENT# raise ValueError ( 'matrices are not aligned' ) #NEWLINE# #UNINDENT# left = self . reindex ( index = common , copy = False ) #NEWLINE# right = other . reindex ( index = common , copy = False ) #NEWLINE# lvals = left . values #NEWLINE# rvals = right . values #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# left = self #NEWLINE# lvals = self . values #NEWLINE# rvals = np . asarray ( other ) #NEWLINE# if ( lvals . shape [ 0 ] != rvals . shape [ 0 ] ) : #NEWLINE# #INDENT# raise Exception ( ( 'Dot product shape mismatch, %s vs %s' % ( lvals . shape , rvals . shape ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if isinstance ( other , DataFrame ) : #NEWLINE# #INDENT# return self . _constructor ( np . dot ( lvals , rvals ) , index = other . columns ) . __finalize__ ( self ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( other , Series ) : #NEWLINE# #INDENT# return np . dot ( lvals , rvals ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( rvals , np . ndarray ) : #NEWLINE# #INDENT# return np . dot ( lvals , rvals ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise TypeError ( ( 'unsupported type: %s' % type ( other ) ) )