Skip to content

ENH: support CategoricalIndex Followups #9748

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
2 of 5 tasks
jreback opened this issue Mar 29, 2015 · 4 comments
Closed
2 of 5 tasks

ENH: support CategoricalIndex Followups #9748

jreback opened this issue Mar 29, 2015 · 4 comments
Labels
Categorical Categorical Data Type Enhancement Index Related to the Index class or subclasses

Comments

@jreback
Copy link
Contributor

jreback commented Mar 29, 2015

followup to #9741

These are all commented in pandas/core/test_frame/test_categorical_indexing_index

  • support slice semantics
  • fix index name issue on selection for non-existant label that IS in the categories
  • fix index name issue on assignment for non-existan label that IS in the categories
  • duplicated returns Boolean array? / test
  • in repr, use max_categories/max_seq_len to display a truncated view

These last 2 were 'solved' by putting the following in core/internals/reindex_indexer
but this caused some issues as the MultiIndex._shallow_copy is really a view semantic (so that needs to be fixed as well)

# make sure that we propogate the correct meta data for this axis
# we need to do this because we are not doing a take / reindex
# which would do this automatically
new_axis = self.axes[axis]._shallow_copy(new_axis)
In [1]: In [4]: df = DataFrame({'A' : np.arange(6,dtype='int64'),
   ...:    ...:                 'B' : Series(list('aabbca')).astype('category',categories=list('cabe')) }).set_index('B')

In [2]: df
Out[2]: 
   A
B   
a  0
a  1
b  2
b  3
c  4
a  5

In [3]: df.loc['e'] = 20

In [4]: df
Out[4]: 
    A
a   0
a   1
b   2
b   3
c   4
a   5
e  20
@jreback jreback added Enhancement Indexing Related to indexing on series/frames, not to indexes themselves Categorical Categorical Data Type labels Mar 29, 2015
@jreback jreback added this to the 0.16.1 milestone Mar 29, 2015
@jreback jreback modified the milestones: 0.17.0, 0.16.1 Apr 28, 2015
@TomAugspurger
Copy link
Contributor

This is tangentially related. I think that the .categories object should return a CategoricalIndex instead of a regular Index like is does now. My need right now is to be able to reindex a categorical with a .categories. We decided to have .reindex(Index) have an Index and .reindex(CategoricalIndex) have a CategoricalIndex. Should I open a separate issue? That should be a quick fix.

@jreback
Copy link
Contributor Author

jreback commented Aug 2, 2015

@TomAugspurger that sounds right. I thought we discussed that in another issue (but can't find right now).

@TomAugspurger
Copy link
Contributor

Ok, I'll do that now since it will simplify my categorical value_counts code a lot.

@jreback jreback modified the milestones: Next Major Release, 0.17.0 Aug 26, 2015
@jreback jreback modified the milestones: 0.18.1, Next Major Release Mar 12, 2016
@jreback jreback modified the milestones: Next Major Release, 0.18.1 Apr 26, 2016
@toobaz toobaz added Index Related to the Index class or subclasses and removed Indexing Related to indexing on series/frames, not to indexes themselves labels Jun 28, 2019
@mroeschke mroeschke removed this from the Contributions Welcome milestone Oct 13, 2022
@mroeschke
Copy link
Member

I think a lot of these have already been addressed so closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Enhancement Index Related to the Index class or subclasses
Projects
None yet
Development

No branches or pull requests

5 participants