Skip to content

Signature of get_level_values not as documented #15681

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
steamelephant opened this issue Mar 14, 2017 · 1 comment
Closed

Signature of get_level_values not as documented #15681

steamelephant opened this issue Mar 14, 2017 · 1 comment

Comments

@steamelephant
Copy link

import numpy as np 
import pandas as pd

data = pd.DataFrame(np.arange(8).reshape(2,4)).set_index([0,1])

print(type(data.index.get_level_values(0)))

returns

<class 'pandas.indexes.numeric.Int64Index'>

while docs say it should return an ndarray.

The actual behaviour is probably useful and the documented behaviour can be obtained by for example:
data.index.get_level_values(0).values
so the situation could be improved by updating the docstring but I think the name could be better.

version info:

INSTALLED VERSIONS

commit: None
python: 3.6.0.final.0
python-bits: 64
OS: Linux
OS-release: 4.8.0-42-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8

pandas: 0.19.2
nose: 1.3.7
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.25.2
numpy: 1.11.3
scipy: 0.18.1
statsmodels: 0.6.1
xarray: 0.9.1
IPython: 5.1.0
sphinx: 1.5.1
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: 1.2.0
tables: 3.3.0
numexpr: 2.6.1
matplotlib: 2.0.0
openpyxl: 2.4.1
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: 0.9.6
lxml: 3.7.2
bs4: 4.5.3
html5lib: 0.999
httplib2: None
apiclient: None
sqlalchemy: 1.1.5
pymysql: None
psycopg2: None
jinja2: 2.9.4
boto: 2.45.0
pandas_datareader: None

@chris-b1
Copy link
Contributor

Thanks for the report - this is corrected on master, was fixed as part of #15245

In [36]: pd.__version__
Out[36]: '0.19.0+566.g54e71a7'

In [37]: data.index.get_level_values?
Signature: data.index.get_level_values(level)
Docstring:
Return vector of label values for requested level,
equal to the length of the index

Parameters
----------
level : int or level name

Returns
-------
values : Index

@chris-b1 chris-b1 added this to the No action milestone Mar 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants