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

BUG: Incorrect TypeError for CategoricalIndex.view('i8') #25464

Closed
simonjayhawkins opened this issue Feb 27, 2019 · 2 comments · Fixed by #45300
Closed

BUG: Incorrect TypeError for CategoricalIndex.view('i8') #25464

simonjayhawkins opened this issue Feb 27, 2019 · 2 comments · Fixed by #45300
Labels
Error Reporting Incorrect or improved errors from pandas good first issue Needs Tests Unit test(s) needed to prevent regressions
Milestone

Comments

@simonjayhawkins
Copy link
Member

xref #25447 (comment)

Code Sample, a copy-pastable example if possible

import pandas.util.testing as tm
ind = tm.makeCategoricalIndex(100)
ind.view('i8')

Problem description

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-11-5cb1f6f042dd> in <module>()
      1 import pandas.util.testing as tm
      2 ind = tm.makeCategoricalIndex(100)
----> 3 ind.view('i8')

~\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in view(self, cls)
    913         # index type here
    914         if cls is not None and not hasattr(cls, '_typ'):
--> 915             result = self._data.view(cls)
    916         else:
    917             result = self._shallow_copy()

TypeError: view() takes 1 positional argument but 2 were given

Expected Output

TypeError: Cannot change data-type for object array

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.5.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 69 Stepping 1, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.23.0
pytest: 3.5.1
pip: 10.0.1
setuptools: 39.1.0
Cython: 0.28.2
numpy: 1.14.3
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 6.4.0
sphinx: 1.7.4
patsy: 0.5.0
dateutil: 2.7.3
pytz: 2018.4
blosc: None
bottleneck: 1.2.1
tables: 3.4.3
numexpr: 2.6.5
feather: None
matplotlib: 2.2.2
openpyxl: 2.5.3
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.0.4
lxml: 4.2.1
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: 1.2.7
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

@WillAyd WillAyd added the Error Reporting Incorrect or improved errors from pandas label Feb 27, 2019
@WillAyd WillAyd added this to the Contributions Welcome milestone Feb 27, 2019
@jbrockmendel
Copy link
Member

This has apparently changed since the OP. Now view('i8') raises TypeError: view() takes 1 positional argument but 2 were given.

@mroeschke
Copy link
Member

This error message is a better now IMO. Could use a test

In [25]: import pandas.util.testing as tm
    ...: ind = tm.makeCategoricalIndex(100)
    ...: ind.view('i8')
NotImplementedError: i8

@mroeschke mroeschke added good first issue Needs Tests Unit test(s) needed to prevent regressions labels Jun 27, 2021
@jreback jreback modified the milestones: Contributions Welcome, 1.5 Jan 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas good first issue Needs Tests Unit test(s) needed to prevent regressions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants