-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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: Int64Index, UInt64Index & Float64Index #43028
DEPR: Int64Index, UInt64Index & Float64Index #43028
Conversation
pandas/core/indexes/numeric.py
Outdated
Notes | ||
----- | ||
An NumericIndex instance can **only** contain numpy int64/32/16/8, uint64/32/16/8 or | ||
float64/32/16 dtype. In Particulat, ``NumericIndex`` *can not* hold Pandas numeric |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Particulat
-> particular
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
fcf5cd6
to
5afecb2
Compare
xref #43002 |
098f9b0
to
ce2c306
Compare
IMHO, we probably should emit some sort of warning to users. I'm a little worried since 2.0 should be the next release after 1.4, and this is a somewhat big change. We can always suppress the deprecation warnings internally. |
I've made a new version where accessing >>> import pandas as pd
>>> idx = pd.Int64Index([8, 9])
FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.NumericIndex with the appropriate dtype instead.
>>> isinstance(idx, pd.Int64Index)
FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.NumericIndex with the appropriate dtype instead.
True but this does not: >>> idx = pd.Index([8, 9])
>>> idx
Int64Index([8, 9], dtype='int64')
>>> isinstance(idx, pd.NumericIndex)
True This last example doesn’t give warnings, because this access pattern is not deprecated, but will only change meaning in Pandas 2.0 (will return a NumericIndex rather than a Int64Index, + Int64Index is a subclass of NumericIndex). These warnings should IMO give users a good hint on where they need to update their code to stay compatible in Pandas 2.0. |
Got some failures still, but will work on them. The idea is completed, so commentd welcome. |
d5a0689
to
33bb44f
Compare
doc/source/user_guide/advanced.rst
Outdated
In pandas 2.0, :class:`NumericIndex` will become the default index type for numeric types | ||
instead of ``Int64Index``, ``Float64Index`` and ``UInt64Index`` and those index types | ||
will be removed. See :ref:`here <advanced.numericindex>` for more. | ||
are therefore deprecated and will be removed in Pandas 2.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of saying Pandas 2.0, just a future version (we don't explicitly list the removal versions anywhere else i believe)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment applies to all docs below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you push the update?
__deprecated_num_index_names = ["Float64Index", "Int64Index", "UInt64Index"] | ||
|
||
|
||
def __dir__(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so Int64Index etc. show up in dir calls.
Int64Index etc. have been quite prominent parts of the public API, so I think it's better that they still show up for the duration of Pandas 1.x. This should be removed in Pandas 2.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok can you add a comment to this effect
Updated. |
Gentle ping… |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very small comment, pls rebase
doc/source/user_guide/advanced.rst
Outdated
will be removed. | ||
``RangeIndex`` however, will not be removed, as it represents an optimized version of an integer index. | ||
instead of :class:`Int64Index`, :class:`Float64Index` and :class:`UInt64Index` and those index types | ||
are therefore deprecated and will be removed in a futureversion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
future version
60d16df
to
7ca2ef7
Compare
thanks @topper-123 very nice! |
@topper-123 want to enforce this deprecation and rip out some code? |
Deprecates Int64Index, UInt64Index & Float64Index.
I don't think it will be sensible to emit a deprecation warning for these because they have a lot of internal usage as is, so I've just added texts explaining that these are deprecated and will be removed in Pandas 2.0.
EDIT: it does now emit an deprecation warning when accessed from the main namespace. See changes to
pandas.__init__.py
for implementation.