Skip to content

ENH: add sort_categories argument to union_categoricals #13846

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

Conversation

chris-b1
Copy link
Contributor

cc: @JanSchulz, @sinhrks

new_codes = np.concatenate([c.codes for c in to_union])

if sort_categories:
categories = categories.sort_values()
Copy link
Member

Choose a reason for hiding this comment

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

I think sort can be skipped if categories is monotonic-increasing.

@sinhrks sinhrks added Enhancement Categorical Categorical Data Type labels Jul 29, 2016
@sinhrks sinhrks added this to the 0.19.0 milestone Jul 29, 2016
@codecov-io
Copy link

codecov-io commented Jul 29, 2016

Current coverage is 85.28% (diff: 100%)

Merging #13846 into master will increase coverage by 0.03%

@@             master     #13846   diff @@
==========================================
  Files           140        139     -1   
  Lines         50455      50020   -435   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits          43014      42659   -355   
+ Misses         7441       7361    -80   
  Partials          0          0          

Powered by Codecov. Last update 59f2557...3a710f0

# GH 13763
c1 = Categorical(['x', 'y', 'z'])
c2 = Categorical(['a', 'b', 'c'])
result = union_categoricals([c1, c2], sort_categories=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you put companion tests with sort_categories=False

@jreback
Copy link
Contributor

jreback commented Aug 2, 2016

can you add this issue to the whatsnew (just add on to same line where union_categoricals is)

@jreback
Copy link
Contributor

jreback commented Aug 2, 2016

lgtm. @sinhrks pls have a look.

@sinhrks
Copy link
Member

sinhrks commented Aug 2, 2016

lgtm. pls fix the lint issue:)

@chris-b1
Copy link
Contributor Author

chris-b1 commented Aug 3, 2016

@sinhrks - updated, thanks!

@jreback jreback closed this in 3db3365 Aug 3, 2016
@jreback
Copy link
Contributor

jreback commented Aug 3, 2016

thanks!

@chris-b1 chris-b1 deleted the union_categoricals_ordered branch August 3, 2016 23:43
jreback pushed a commit that referenced this pull request Aug 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants