Skip to content

CLN: use 'codes' rather than 'values' internally in Categorical #22547

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

Merged
merged 1 commit into from
Aug 31, 2018

Conversation

topper-123
Copy link
Contributor

In some places a variable has the name values, where codes would be more logical, as we're dealing with codes.

This makes it a bit easier to understand what we're looking at when reading IMO,

cat = Categorical(values,
categories=self.categories,
ordered=self.ordered)
cat = Categorical(values, dtype=self.dtype)
Copy link
Member

Choose a reason for hiding this comment

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

Hey- why can we get rid of the categories and ordered params out of interest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The dtype is a CategoricalDtype, which contains attributes categories and ordered. So we're not really removing them, only passinf the dtype around instead, which is clearer IMO.

@jbrockmendel
Copy link
Member

+1 on moving away from ‘values’, too many variants of that exist at the moment

@codecov
Copy link

codecov bot commented Aug 31, 2018

Codecov Report

Merging #22547 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #22547      +/-   ##
==========================================
- Coverage   92.04%   92.04%   -0.01%     
==========================================
  Files         169      169              
  Lines       50783    50782       -1     
==========================================
- Hits        46741    46740       -1     
  Misses       4042     4042
Flag Coverage Δ
#multiple 90.45% <100%> (-0.01%) ⬇️
#single 42.22% <0%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/arrays/categorical.py 95.74% <100%> (-0.01%) ⬇️
pandas/core/indexes/category.py 97.28% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1a798be...77323b8. Read the comment docs.

@jreback jreback added Categorical Categorical Data Type Clean labels Aug 31, 2018
@jreback jreback added this to the 0.24.0 milestone Aug 31, 2018
@jreback jreback merged commit 5f89597 into pandas-dev:master Aug 31, 2018
@jreback
Copy link
Contributor

jreback commented Aug 31, 2018

thanks!

@topper-123 topper-123 deleted the clean_categorical_II branch August 31, 2018 10:02
Sup3rGeo pushed a commit to Sup3rGeo/pandas that referenced this pull request Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Clean
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants