Skip to content

Fix #12564 for Categorical: consistent result if comparing as DataFrame #12698

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

facaiy
Copy link
Contributor

@facaiy facaiy commented Mar 23, 2016


# fix issue #12564: CategoricalBlock is 1-dim only, while category
# datarame can be more.
if getattr(self, 'is_categorical', None) and x.ndim < self.ndim:
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need all of these extra checks which are block specific. does it break when you take them out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. x.ndim < self.ndim
    if x is a normal object, _block_shape will increase x.ndim so that ValueError: Wrong number of dimensions raises. Thus I check x.ndim < self.ndim.
  2. getattr(self, 'is_categorical', None)
    Because we expect that x.ndim < self.ndim should only occur in NonConsolidatableMixIn class, so if it is not the case, I believe that it might be a bug.

Copy link
Contributor

Choose a reason for hiding this comment

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

these are too specific here for this type of general routine. you might want to do this in _try_coerce_results for only Categoricals.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I will take a look at _try_coerce_results. Thanks for your advice.

@jreback
Copy link
Contributor

jreback commented Mar 23, 2016

pls add a whatsnew note in Bug Fixes as well (for 0.18.1)

@jreback jreback added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode Categorical Categorical Data Type Indexing Related to indexing on series/frames, not to indexes themselves labels Mar 23, 2016
@facaiy
Copy link
Contributor Author

facaiy commented Mar 23, 2016

ok, I'll add a whatsnew note by tomorrow.

@@ -1874,6 +1874,21 @@ def _slice(self, slicer):
# return same dims as we currently have
return self.values._slice(slicer)

def _try_coerce_args(self, values, other):
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need this

@facaiy
Copy link
Contributor Author

facaiy commented Apr 2, 2016

Thanks for your advice, @jreback.
Is it OK? and do I need to rebase for resolving conflicts?

@TomAugspurger
Copy link
Contributor

@ningchi if you could that'd be great. It's probably just a conflict in the whatsnew file. And if your comfortable you can squash your commits down to a nice single message too.

@jreback
Copy link
Contributor

jreback commented Apr 2, 2016

yes, pls rebase

@facaiy
Copy link
Contributor Author

facaiy commented Apr 3, 2016

many thanks! I have rebased these commits.

@jreback jreback added this to the 0.18.1 milestone Apr 3, 2016
@jreback jreback closed this in ad8ade8 Apr 3, 2016
@jreback
Copy link
Contributor

jreback commented Apr 3, 2016

thanks @ningchi

@facaiy facaiy deleted the issue12669 branch April 8, 2016 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Categorical Categorical Data Type Indexing Related to indexing on series/frames, not to indexes themselves Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Categorical equality check raises ValueError in DataFrame
3 participants