-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: update the DataFrame.combine and DataFrame.combine_first docstrings #20237
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
DOC: update the DataFrame.combine and DataFrame.combine_first docstrings #20237
Conversation
… Added descriptions to parameters. Added examples to demonstrate quirks in usage.
… Added descriptions to parameters. Added examples to demonstrate quirks in usage.
…ndas into document_frame_combine
…frame.combine_first
…or proper HTML formatting.
Would to like to give recognition to @qshng who worked on this documentation with me. |
pandas/core/frame.py
Outdated
Perform series-wise combine with `other` DataFrame using given `func`. | ||
|
||
Combines `self` DataFrame with `other` DataFrame using `func` | ||
to merge columns. The row and column indexes of the resulting |
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.
merge is a very specific word and would rather not use it here. element-wise combine is pretty descriptive
pandas/core/frame.py
Outdated
|
||
Combines `self` DataFrame with `other` DataFrame using `func` | ||
to merge columns. The row and column indexes of the resulting | ||
DataFrame will be the union of the two. If `fill_value` is |
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.
you are describing the parameters here (and they are described below). I think your first 2 sentences are pretty good.
pandas/core/frame.py
Outdated
>>> df1 = DataFrame({'A': [0, 0], 'B': [4, 4]}) | ||
>>> df2 = DataFrame({'A': [1, 1], 'B': [3, 3]}) | ||
>>> df1.combine(df2, lambda s1, s2: s1 if s1.sum() < s2.sum() else s2) | ||
>>> take_smaller = lambda s1, s2: s1 if s1.sum() < s2.sum() else s2 |
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.
would also show something like:
In [14]: df1 = DataFrame({'A': [0, 0], 'B': [4, 4]})
...: df2 = DataFrame({'A': [1, 1], 'B': [3, 3]})
...:
In [15]: df1.combine(df2, np.minimum)
Out[15]:
A B
0 0 3
1 0 3
pandas/core/frame.py
Outdated
>>> df2 = DataFrame({'A': [1, 1], 'B': [3, 3]}) | ||
>>> df1.combine(df2, take_smaller, fill_value=-5) | ||
A B | ||
0 0 -5.0 |
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.
these should be aligned
In [18]: df1 = DataFrame({'A': [0, 0], 'B': [None, 4]})
...: df2 = DataFrame({'A': [1, 1], 'B': [3, 3]})
...: df1.combine(df2, take_smaller, fill_value=-5)
...:
Out[18]:
A B
0 0 -5.0
1 0 4.0
pandas/core/frame.py
Outdated
2 NaN 3.0 1.0 | ||
|
||
Demonstrating the preference of the passed in dataframe. | ||
>>> df2 = DataFrame({'B': [3, 3], 'C': [1, 1],}, index=[1, 2]) |
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.
can you be consistent about blank lines before an example (e.g. add one here)
pandas/core/frame.py
Outdated
|
||
>>> df1.combine(df2, take_smaller, overwrite=False) | ||
A B C | ||
0 0.0 NaN NaN |
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.
alignment on these
…g- addressing review comments
The
And for
|
Hello @Michael-J-Ward! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on July 07, 2018 at 19:58 Hours UTC |
Thanks @Michael-J-Ward! (Travis error was from a prior lint error on master) |
…ngs (pandas-dev#20237) * Added summary to `DataFrame.combine`. Corrected the extended summary. Added descriptions to parameters. Added examples to demonstrate quirks in usage. * Added summary to `DataFrame.combine`. Corrected the extended summary. Added descriptions to parameters. Added examples to demonstrate quirks in usage. * Added short summary to and added examples to demonstrate behavior. * pep8 formatting for the docstrings * updated doctests so that they all pass for Dataframe.combine and Dataframe.combine_first * updated docstrings on DataFrame.combine and DataFrame.combine_first for proper HTML formatting. * updated output alignment and removed term merge from combine docstring- addressing review comments * remove unneeded files and some edits * forgot some pd * flake8 and edit combine_first
Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):
scripts/validate_docstrings.py <your-function-or-method>
git diff upstream/master -u -- "*.py" | flake8 --diff
python doc/make.py --single <your-function-or-method>
Please include the output of the validation script below between the "```" ticks:
For
DataFrame.combine_first