Skip to content

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

Merged
merged 3 commits into from
Jun 22, 2020
Merged

DOC: Improve docstring of Series/DataFrame.bool #34229

merged 3 commits into from
Jun 22, 2020

Conversation

datapythonista
Copy link
Member

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.

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a 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)

--------
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

Copy link
Member Author

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?

Copy link
Member

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

@jreback
Copy link
Contributor

jreback commented Jun 20, 2020

can you merge master and update

@jorisvandenbossche jorisvandenbossche added this to the 1.1 milestone Jun 22, 2020
@jorisvandenbossche jorisvandenbossche merged commit 8ba9c62 into pandas-dev:master Jun 22, 2020
@jorisvandenbossche
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants