def dot(self, other):
if isinstance(other, (Series, DataFrame)):<EOL><INDENT>common = self.columns.union(other.index)<EOL>if (len(common) > len(self.columns) or<EOL>len(common) > len(other.index)):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>left = self.reindex(columns=common, copy=False)<EOL>right = other.reindex(index=common, copy=False)<EOL>lvals = left.values<EOL>rvals = right.values<EOL><DEDENT>else:<EOL><INDENT>left = self<EOL>lvals = self.values<EOL>rvals = np.asarray(other)<EOL>if lvals.shape[<NUM_LIT:1>] != rvals.shape[<NUM_LIT:0>]:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'.format(s=lvals.shape,<EOL>r=rvals.shape))<EOL><DEDENT><DEDENT>if isinstance(other, DataFrame):<EOL><INDENT>return self._constructor(np.dot(lvals, rvals), index=left.index,<EOL>columns=other.columns)<EOL><DEDENT>elif isinstance(other, Series):<EOL><INDENT>return Series(np.dot(lvals, rvals), index=left.index)<EOL><DEDENT>elif isinstance(rvals, (np.ndarray, Index)):<EOL><INDENT>result = np.dot(lvals, rvals)<EOL>if result.ndim == <NUM_LIT:2>:<EOL><INDENT>return self._constructor(result, index=left.index)<EOL><DEDENT>else:<EOL><INDENT>return Series(result, index=left.index)<EOL><DEDENT><DEDENT>else:  <EOL><INDENT>raise TypeError('<STR_LIT>'.format(oth=type(other)))<EOL><DEDENT>
Compute the matrix mutiplication between the DataFrame and other.

This method computes the matrix product between the DataFrame and the
values of an other Series, DataFrame or a numpy array.

It can also be called using ``self @ other`` in Python >= 3.5.

Parameters
----------
other : Series, DataFrame or array-like
    The other object to compute the matrix product with.

Returns
-------
Series or DataFrame
    If other is a Series, return the matrix product between self and
    other as a Serie. If other is a DataFrame or a numpy.array, return
    the matrix product of self and other in a DataFrame of a np.array.

See Also
--------
Series.dot: Similar method for Series.

Notes
-----
The dimensions of DataFrame and other must be compatible in order to
compute the matrix multiplication.

The dot method for Series computes the inner product, instead of the
matrix product here.

Examples
--------
Here we multiply a DataFrame with a Series.

>>> df = pd.DataFrame([[0, 1, -2, -1], [1, 1, 1, 1]])
>>> s = pd.Series([1, 1, 2, 1])
>>> df.dot(s)
0    -4
1     5
dtype: int64

Here we multiply a DataFrame with another DataFrame.

>>> other = pd.DataFrame([[0, 1], [1, 2], [-1, -1], [2, 0]])
>>> df.dot(other)
    0   1
0   1   4
1   2   2

Note that the dot method give the same result as @

>>> df @ other
    0   1
0   1   4
1   2   2

The dot method works also if other is an np.array.

>>> arr = np.array([[0, 1], [1, 2], [-1, -1], [2, 0]])
>>> df.dot(arr)
    0   1
0   1   4
1   2   2