-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: Upgraded Docstring pandas.DataFrame.dot #23024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jreback
merged 6 commits into
pandas-dev:master
from
HubertKl:docstring_pandas_DataFrame_dot
Dec 19, 2018
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b1f5fca
DOC: Updated docstring pandas.DataFrame.dot
04268cc
DOC: Updated docstring pandas.DataFrame.dot
a7ce612
minor update
ad724da
conflict resolved
997cbe6
corrections
89e2be4
Merge remote-tracking branch 'upstream/master' into docstring_pandas_…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1046,16 +1046,71 @@ def __len__(self): | |
|
||
def dot(self, other): | ||
""" | ||
Matrix multiplication with DataFrame or Series objects. Can also be | ||
called using `self @ other` in Python >= 3.5. | ||
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 : DataFrame or Series | ||
other : Series, DataFrame or array-like | ||
The other object to compute the matrix product with. | ||
|
||
Returns | ||
------- | ||
dot_product : DataFrame or Series | ||
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: Compute the inner product of a Series with another Series | ||
or the columns of a DataFrame or the columns of a numpy array. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you say instead "Same method for Series." or similar if that makes sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you mind changing this? |
||
|
||
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 | ||
""" | ||
if isinstance(other, (Series, DataFrame)): | ||
common = self.columns.union(other.index) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry I didn't see that before, for code we use double backticks (single backticks are for things we reference, like a function name, a class, a variable...)