-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: added examples to align function's documentation #42129
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -8517,7 +8517,34 @@ def align( | |||||||||||||||
""" | ||||||||||||||||
|
||||||||||||||||
method = missing.clean_fill_method(method) | ||||||||||||||||
|
||||||||||||||||
""" | ||||||||||||||||
Examples | ||||||||||||||||
-------- | ||||||||||||||||
>>> df1 = pd.DataFrame([[1,2,3,4], [6,7,8,9]], | ||||||||||||||||
columns=['D', 'B', 'E', 'A'], index=[1,2]) | ||||||||||||||||
Comment on lines
+8523
to
+8524
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. also, the formatting's a bit strange here, it would be better to either format your example with
Suggested change
(same for the other parts of the example) |
||||||||||||||||
>>> df2 = pd.DataFrame([[10,20,30,40], [60,70,80,90], [600,700,800,900]], | ||||||||||||||||
columns=['A', 'B', 'C', 'D'], index=[2,3,4]) | ||||||||||||||||
|
||||||||||||||||
>>> a1, a2 = df1.align(df2, join='outer', axis=1) | ||||||||||||||||
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. perhaps call these |
||||||||||||||||
>>> a1 | ||||||||||||||||
A B C D E | ||||||||||||||||
1 4 2 NaN 1 3 | ||||||||||||||||
2 9 7 NaN 6 8 | ||||||||||||||||
>>> a2 | ||||||||||||||||
A B C D E | ||||||||||||||||
2 10 20 30 40 NaN | ||||||||||||||||
3 60 70 80 90 NaN | ||||||||||||||||
4 600 700 800 900 NaN | ||||||||||||||||
|
||||||||||||||||
>>> a1, a2 = df1.align(df2, join='inner', axis=None) | ||||||||||||||||
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. likewise |
||||||||||||||||
>>> a1 | ||||||||||||||||
D B A | ||||||||||||||||
2 6 7 9 | ||||||||||||||||
>>> a2 | ||||||||||||||||
D B A | ||||||||||||||||
2 40 20 10 | ||||||||||||||||
""" | ||||||||||||||||
|
||||||||||||||||
if broadcast_axis == 1 and self.ndim != other.ndim: | ||||||||||||||||
if isinstance(self, ABCSeries): | ||||||||||||||||
# this means other is a DataFrame, and we need to broadcast | ||||||||||||||||
|
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.
this shouldn't be removed
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.
I addressed this in the last commit