Skip to content

COMPAT: Categorical Subclassing #13827

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

Closed
wants to merge 1 commit into from

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented Jul 28, 2016

It allows to subclass Categorical related to #8640. Shoud it use _simple_new or _constructor?

@sinhrks sinhrks added the Categorical Categorical Data Type label Jul 28, 2016
@sinhrks sinhrks added this to the 0.19.0 milestone Jul 28, 2016
@sinhrks sinhrks added the Compat pandas objects compatability with Numpy or Python functions label Jul 28, 2016
@codecov-io
Copy link

codecov-io commented Jul 28, 2016

Current coverage is 85.28% (diff: 94.73%)

Merging #13827 into master will decrease coverage by <.01%

@@             master     #13827   diff @@
==========================================
  Files           139        139          
  Lines         50057      50062     +5   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          42692      42695     +3   
- Misses         7365       7367     +2   
  Partials          0          0          

Powered by Codecov. Last update 45d54d0...13c456c

@shoyer
Copy link
Member

shoyer commented Jul 28, 2016

The changes in this PR are fine, but I'm not sure it's a good idea to subclassing Categorical in the API, though I would guess nothing major is likely to change before v2.0. Categorical is diving pretty far into pandas internals.

@sinhrks
Copy link
Member Author

sinhrks commented Jul 28, 2016

It may better to discuss in #8640, I' m thinking the following stricture:

  • CategoricalMixin ( move internal methods related to _categories and _codes)
    • Categorical (no API change)
    • String (automatically handle _categories, _codes and .str methods)

I don't think we have to wait for 2.0 as long as it does't break existing user's code, but it also should be discussed separatelly (in ML).

@@ -330,9 +330,9 @@ def __init__(self, values, categories=None, ordered=False,

def copy(self):
""" Copy constructor. """
return Categorical(values=self._codes.copy(),
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe make a _constructor as that is the patter we are using for other classes

@sinhrks sinhrks force-pushed the categorical_subclass branch 2 times, most recently from 1a08cf9 to 55a195b Compare August 4, 2016 09:01
@sinhrks
Copy link
Member Author

sinhrks commented Aug 4, 2016

Updated to use _constructor and added small number of tests.

@sinhrks sinhrks force-pushed the categorical_subclass branch from 55a195b to 13c456c Compare August 4, 2016 09:04
@jreback jreback closed this in 61b14b2 Aug 4, 2016
@jreback
Copy link
Contributor

jreback commented Aug 4, 2016

ty!

@sinhrks sinhrks deleted the categorical_subclass branch August 4, 2016 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Compat pandas objects compatability with Numpy or Python functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants