Skip to content

CLN/DOC/TST: categorical fixups (GH7768) #8006

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

jreback
Copy link
Contributor

@jreback jreback commented Aug 12, 2014

replaces #7768

closes #3678

Categorical([1, np.nan]) would end up with a single 1. float level.
This commit ensures that if values is a list of ints and contains np.nan,
the float conversation does not take place.

Categorical: fix describe with np.nan

Categorical: ensure that one can assign np.nan

Categorical: fix assigning NaN if NaN in levels

API: change default Categorical.from_codes() to ordered=False

In the normal constructor ordered=True is only assumed if the levels
are given or the values are sortable (which is most of the cases), but
in from_codes(...) we can't asssume this so the default should be
False.

Categorical: add some links to Categorical in the other docs

Categorical: use s.values when calling private methods

s.values is the underlying Categorical object, s.cat will be changed
to only expose the API methods/properties.

Categorical: Change series.cat to only expose the API

Categorical: Fix order and na_position

Categorical: Fix comparison of Categoricals and Series|Categorical|np.array

Categorical can only be comapred to another Categorical with the same levels
and the same ordering or to a scalar value.

If the Categorical has no order defined (cat.ordered == False), only equal
(and not equal) are defined.

DOC: use okexcept in docs rather than try: except:

CLN: revised isnull treatement

TST: test for tab completion

@jreback jreback added this to the 0.15.0 milestone Aug 12, 2014
@jreback jreback mentioned this pull request Aug 12, 2014
5 tasks
@@ -208,8 +232,23 @@ def __init__(self, values, levels=None, ordered=None, name=None, fastpath=False,
# under certain versions of numpy as well
inferred = com._possibly_infer_to_datetimelike(values)
if not isinstance(inferred, np.ndarray):

# isnull doesn't work with generators/xrange, so convert all to lists
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JanSchulz this whole biz seems to work, but seems a bit clunky, let's revisit at some point.

closes GH3678

Categorical([1, np.nan]) would end up with a single `1.` float level.
This commit ensures that if `values` is a list of ints and contains np.nan,
the float conversation does not take place.

Categorical: fix describe with np.nan

Categorical: ensure that one can assign np.nan

Categorical: fix assigning NaN if NaN in levels

API: change default Categorical.from_codes() to ordered=False

In the normal constructor `ordered=True` is only assumed if the levels
are given or the values are sortable (which is most of the cases), but
in `from_codes(...)` we can't asssume this so the default should be
`False`.

Categorical: add some links to Categorical in the other docs

Categorical: use s.values when calling private methods

s.values is the underlying Categorical object, s.cat will be changed
to only expose the API methods/properties.

Categorical: Change series.cat to only expose the API

Categorical: Fix order and na_position

Categorical: Fix comparison of Categoricals and Series|Categorical|np.array

Categorical can only be comapred to another Categorical with the same levels
and the same ordering or to a scalar value.

If the Categorical has no order defined (cat.ordered == False), only equal
(and not equal) are defined.

DOC: use okexcept in docs rather than try: except:

CLN: revised isnull treatement

TST: test for tab completion
@jreback
Copy link
Contributor Author

jreback commented Aug 12, 2014

closing in favor of new one from @JanSchulz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Categoricals with NaNs
2 participants