-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: Improve docstring of Series/DataFrame.bool #34229
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: Improve docstring of Series/DataFrame.bool #34229
Conversation
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.
Small comment (and I agree that this method doesn't sound very useful (never used it myself), there is also .item()
for Series that does exactly the same but for all data types and not just bool)
pandas/core/generic.py
Outdated
-------- | ||
Series.astype : Change the data type of a Series, including to boolean. | ||
DataFrame.astype : Change the data type of a DataFrame, including to boolean. | ||
numpy.bool : NumPy boolean data type, used by pandaas for boolean values. |
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.
numpy.bool : NumPy boolean data type, used by pandaas for boolean values. | |
numpy.bool : NumPy boolean data type, used by pandas for boolean values. |
Two notes: this is not actually the boolean data type (but an alias for built-in bool, the numpy one is np.bool_
), and is this reference actually useful? (the method returns a builtin bool, not a numpy one)
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.
Good points, thanks for the feedback.
What I had in mind is that given the name of the method, users may come to this page looking for a way to convert a Series or a DataFrame to boolean (like elementwise). I was trying to add references that may be useful for them. Didn't think of item
, but may be could be added here too. Also, not sure if any
and all
could be useful to some visitors.
Also happy to remove 'numpy.bool_`, it's difficult to draw the line of what could be useful and what is too much.
What would you have?
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 for the slow reply, fixing it up to refer to np.bool_
instead of np.bool
is fine for me
can you merge master and update |
Thanks! |
Not a big fan of this method, I'd deprecate it, in favor of
bool(df.squeeze())
. But since it's quite tricky, let's at least have the docstring as clear as possible.