Skip to content

BUG/TYP: 1.3.0 index.values returns ExtensionArray | ndarray instead of ndarray #42002

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
2 of 3 tasks
twoertwein opened this issue Jun 14, 2021 · 2 comments
Closed
2 of 3 tasks
Labels
Closing Candidate May be closeable, needs more eyeballs Typing type annotations, mypy/pyright type checking

Comments

@twoertwein
Copy link
Member

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Probably an intended change, but I didn't find anything related to it in the whatsnew.

import pandas as pd

df = pd.DataFrame({"a": [1]})

reveal_type(df.values)
reveal_type(df.index.values)

pyright with 1.2.4

info: Type of "df.values" is "ndarray"
info: Type of "df.index.values" is "ndarray"

pyright with 1.3.0.rc1

info: Type of "df.values" is "ndarray"
info: Type of "df.index.values" is "ExtensionArray | ndarray"
@twoertwein twoertwein added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 14, 2021
@jorisvandenbossche
Copy link
Member

That seems a correct change indeed

I didn't find anything related to it in the whatsnew.

I don't think we generally list typing changes/fixes in the whatsnew

@jorisvandenbossche jorisvandenbossche added Typing type annotations, mypy/pyright type checking and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 15, 2021
@simonjayhawkins
Copy link
Member

That seems a correct change indeed

agreed.

@property
def values(self) -> ArrayLike:
"""
Return an array representing the data in the Index.
.. warning::
We recommend using :attr:`Index.array` or
:meth:`Index.to_numpy`, depending on whether you need
a reference to the underlying data or a NumPy array.
Returns
-------
array: numpy.ndarray or ExtensionArray
See Also
--------
Index.array : Reference to the underlying data.
Index.to_numpy : A NumPy array representing the underlying data.
"""
return self._data

I don't think we generally list typing changes/fixes in the whatsnew

agreed. the type of the property is unchanged. only the type annotation has been changed (in #38531)

@simonjayhawkins simonjayhawkins added the Closing Candidate May be closeable, needs more eyeballs label Jun 15, 2021
@simonjayhawkins simonjayhawkins added this to the No action milestone Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closing Candidate May be closeable, needs more eyeballs Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

No branches or pull requests

3 participants