forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG/API: Accessors like .cat raise AttributeError when invalid
`AttributeError` is really the appropriate error to raise for an invalid attribute. In particular, it is necessary to ensure that tests like `hasattr(s, 'cat')` work consistently on Python 2 and 3: on Python 2, `hasattr(s, 'cat')` will return `False` even if a `TypeError` was raised, but Python 3 more strictly requires `AttributeError`. This is an unfortunate trap that we should avoid. See this discussion in Seaborn for a full report: mwaskom/seaborn#361 (comment) Note that technically, this is an API change, since these accessors (all but `.str`, I think) raised TypeError in the last release. This also suggests another possibility for testing for Series with a Categorical dtype (GH8814): just use `hasattr(s, 'cat')` (at least for Python 2 or pandas >=0.16). CC mwaskom jorisvandenbossche JanSchulz
- Loading branch information
Showing
6 changed files
with
28 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters