Skip to content

TST/DOC: Fix tests and docs for .cat raising AttributeError if invalid #9629

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 1 commit into from
Mar 11, 2015

Conversation

shoyer
Copy link
Member

@shoyer shoyer commented Mar 11, 2015

Follow-up on #9617

Fixes #8814 -- is it fair to say that hasattr(s, 'cat') is probably
the best solution we're going to come up with for checking for categorical
data?

CC @jreback @jorisvandenbossche @JanSchulz

Follow-up on GH9617

Fixes GH8814 -- is it fair to say that ``hasattr(s, 'cat')`` is probably
the best solution we're going to come up with for checking for categorical
data?
@shoyer shoyer added Build Library building on various platforms Docs Categorical Categorical Data Type labels Mar 11, 2015
@shoyer shoyer added this to the 0.16.0 milestone Mar 11, 2015
To check if a Series contains Categorical data, with pandas 0.16 or later, use
``hasattr(s, 'cat')``:

.. ipython:: python
Copy link
Member

Choose a reason for hiding this comment

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

can you add a :okexcept: option to the directive here (so the doc building does not issue a warning for the failure)?

Copy link
Member Author

Choose a reason for hiding this comment

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

hasattr catches the error, so I don't think that's necessary?

Copy link
Member

Choose a reason for hiding this comment

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

ah, yes, sorry, I was looking too quickly, thought you were giving an example of that accessing the attribute raises, but it is hasattr, not getattr ..

@shoyer
Copy link
Member Author

shoyer commented Mar 11, 2015

FYI this commit passed on my fork so we can safely merge this: https://travis-ci.org/shoyer/pandas/builds/53882855

@jreback
Copy link
Contributor

jreback commented Mar 11, 2015

ok, looks ok to me. go ahead and merge.

shoyer added a commit that referenced this pull request Mar 11, 2015
TST/DOC: Fix tests and docs for .cat raising AttributeError if invalid
@shoyer shoyer merged commit a162728 into pandas-dev:master Mar 11, 2015
@shoyer shoyer deleted the fix-accessors-raise-AttributeError branch March 11, 2015 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Library building on various platforms Categorical Categorical Data Type Docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: preferred way to check if column/Series has Categorical dtype
3 participants