-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Added example to NDFrame.where #13798
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
Conversation
________ | ||
|
||
>>> df = pd.DataFrame(np.arange(10).reshape(-1, 2), columns=['A', 'B']) | ||
>>> df.where(df % 3, -df) |
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.
as cond
should be a boolean DataFrame
, df % 3 != 0
is better as an example. Also, I prefer arange(1, 11)
because -0 = 0
(or whatever example that user can clearly understand).
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.
Noted and updated!
________ | ||
|
||
>>> df = pd.DataFrame(np.arange(10).reshape(-1, 2), columns=['A', 'B']) | ||
>>> df.where(df % 3 == 0, -df) |
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.
Changed to boolean DataFrame and flipped bools so as to not induce confusion with 0 -> -0 -> 0.
I think adding how this can emulate np.where would also be useful (add in a Note section for that) |
from your expl on SO |
Current coverage is 85.28% (diff: 100%)@@ master #13798 diff @@
==========================================
Files 139 139
Lines 50214 50214
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 42822 42823 +1
+ Misses 7392 7391 -1
Partials 0 0
|
to `np.where(m, df1, df2`. | ||
|
||
Examples | ||
________ |
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 use dashes (-
) instead of underscores (_
)?
Thanks for feedback! |
Notes | ||
----- | ||
The signature for :func:`DataFrame.where` differs from | ||
:func:`numpy.where`. Roughly ``df1.where(m, df2)`` is equivalent to |
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 don't need the double-backticks here as this is not markdown.
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.
jeff, it's the other way around :-) (it's markdown that does not need double backticks)
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.
my bad, @jorisvandenbossche is right!
can you update |
Yep, will do. On Tue, Aug 9, 2016 at 7:23 PM Jeff Reback [email protected] wrote:
|
I noticed that most examples on the method's page use the |
@jalexvig no, use the doc-string syntax. These are viewable from the command line, not generated docs (they are generated too, but that's not the primary use) |
@jalexvig Thanks a lot! |
No description provided.