Skip to content
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

DEPR: Change default value for CategoricalDtype.ordered from None to False #29955

Merged
merged 7 commits into from
Dec 9, 2019

Conversation

jschendel
Copy link
Member

@jschendel jschendel commented Dec 2, 2019

A quick summary of the deprecation details can be found here: #26403 (comment)

@jschendel jschendel added Categorical Categorical Data Type Deprecate Functionality to remove in pandas Clean labels Dec 2, 2019
@jschendel jschendel added this to the 1.0 milestone Dec 2, 2019
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

I don't fully remember the previous discussion (should look back at it), but do we want to allow ordered=None in the main constructor? We need it internally to denote a categorical dtype that should not override the ordered property of another one, but do we need to expose this in the public constructor? (could also have a private way to created this)

If we keep it in the public constructor, we should probably document it?

@@ -519,7 +519,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
- Changed :meth:`Timedelta.resolution` to match the behavior of the standard library ``datetime.timedelta.resolution``, for the old behavior, use :meth:`Timedelta.resolution_string` (:issue:`26839`)
- Removed previously deprecated :attr:`Timestamp.weekday_name`, :attr:`DatetimeIndex.weekday_name`, and :attr:`Series.dt.weekday_name` (:issue:`18164`)
- Removed previously deprecated ``errors`` argument in :meth:`Timestamp.tz_localize`, :meth:`DatetimeIndex.tz_localize`, and :meth:`Series.tz_localize` (:issue:`22644`)
-
- Changed the default value for ``ordered`` in :class:`~pandas.api.types.CategoricalDtype` from ``None`` to ``False`` (:issue:`26336`)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- Changed the default value for ``ordered`` in :class:`~pandas.api.types.CategoricalDtype` from ``None`` to ``False`` (:issue:`26336`)
- Changed the default value for ``ordered`` in :class:`~pandas.CategoricalDtype` from ``None`` to ``False`` (:issue:`26336`)

(that's the public path as in the api docs: https://dev.pandas.io/docs/reference/api/pandas.CategoricalDtype.html)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, updated to :class:`CategoricalDtype`

"must be explicitly passed in order to be retained"
)
warnings.warn(msg, FutureWarning, stacklevel=3)
new_ordered = self.ordered
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment here why ordered can be None?

Copy link
Member Author

Choose a reason for hiding this comment

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

There's a comment a little further up that actually addresses this (above the new_categories definition) but as written it's not immediately noticeable. I've shortened the logic for both of these to be ternary statements, which hopefully makes the comment is more observable, and cleaned up the wording of the comment.

@jschendel
Copy link
Member Author

jschendel commented Dec 2, 2019

I don't fully remember the previous discussion (should look back at it), but do we want to allow ordered=None in the main constructor?

I had forgotten too but apparently my past self anticipated this and wrote a nice summary here: #26403 (comment). Also edited my first comment so this link in included at the top of the PR. Looks like the decision was to maintain the ordered=None behavior.

If we keep it in the public constructor, we should probably document it?

I can add some documentation for this in a bit (after sleep + work) if we want to advertise this behavior. There were previously some concerns that this might not be behavior we want to encourage (xref #26403 (comment)) since this is in part an implementation detail to handle "category", and the same behavior can be achieved by explicitly specifying ordered.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

@jbrockmendel
Copy link
Member

@jschendel needs rebase

@jschendel
Copy link
Member Author

merged master and added a note regarding the usage of ordered=None

@jorisvandenbossche
Copy link
Member

@jschendel Thanks for the update and explanation !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Clean Deprecate Functionality to remove in pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLN: Revert internal CategoricalDtype.ordered -> CategoricalDtype._ordered references
4 participants