Skip to content

Unstacking float16 with missing levels throws AttributeError #24445

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
nateyoder opened this issue Dec 26, 2018 · 3 comments
Closed

Unstacking float16 with missing levels throws AttributeError #24445

nateyoder opened this issue Dec 26, 2018 · 3 comments
Labels
Dtype Conversions Unexpected or buggy dtype conversions Duplicate Report Duplicate issue or pull request

Comments

@nateyoder
Copy link
Contributor

Code Sample, a copy-pastable example if possible

index = pd.MultiIndex.from_tuples(
    [
        (1, 'a'), 
        (2, 'a'), 
        (2, 'b'),
    ]
)
ex = pd.DataFrame(np.ones((3, 2), dtype=np.float16), index=index, columns=['foo', 'bar'])
ex.unstack(level=0)

Problem description

This raises an AttributeError:


AttributeError Traceback (most recent call last)
in ()
----> 1 ex.unstack(level=0)

/Users/nate/anaconda2/envs/petinsight/lib/python2.7/site-packages/pandas/core/frame.pyc in unstack(self, level, fill_value)
5532 """
5533 from pandas.core.reshape.reshape import unstack
-> 5534 return unstack(self, level, fill_value)
5535
5536 _shared_docs['melt'] = ("""

/Users/nate/anaconda2/envs/petinsight/lib/python2.7/site-packages/pandas/core/reshape/reshape.pyc in unstack(obj, level, fill_value)
493 if isinstance(obj, DataFrame):
494 if isinstance(obj.index, MultiIndex):
--> 495 return _unstack_frame(obj, level, fill_value=fill_value)
496 else:
497 return obj.T.stack(dropna=False)

/Users/nate/anaconda2/envs/petinsight/lib/python2.7/site-packages/pandas/core/reshape/reshape.pyc in _unstack_frame(obj, level, fill_value)
514 fill_value=fill_value,
515 constructor=obj._constructor)
--> 516 return unstacker.get_result()
517
518

/Users/nate/anaconda2/envs/petinsight/lib/python2.7/site-packages/pandas/core/reshape/reshape.pyc in get_result(self)
182
183 def get_result(self):
--> 184 values, _ = self.get_new_values()
185 columns = self.get_new_columns()
186 index = self.get_new_index()

/Users/nate/anaconda2/envs/petinsight/lib/python2.7/site-packages/pandas/core/reshape/reshape.pyc in get_new_values(self)
246
247 # fill in our values & mask
--> 248 f = getattr(reshape, "unstack{name}".format(name=name))
249 f(sorted_values,
250 mask.view('u1'),

AttributeError: 'module' object has no attribute 'unstack_float16'

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]
INSTALLED VERSIONS

commit: None
python: 2.7.15.final.0
python-bits: 64
OS: Darwin
OS-release: 18.2.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None

pandas: 0.23.4
pytest: 3.8.0
pip: 10.0.1
setuptools: 40.2.0
Cython: 0.28.5
numpy: 1.15.1
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 5.8.0
sphinx: 1.7.9
patsy: 0.5.0
dateutil: 2.7.3
pytz: 2018.5
blosc: 1.5.1
bottleneck: 1.2.1
tables: 3.4.4
numexpr: 2.6.8
feather: None
matplotlib: 2.2.3
openpyxl: 2.5.6
xlrd: 1.1.0
xlwt: 1.2.0
xlsxwriter: 1.1.0
lxml: 4.2.5
bs4: 4.6.3
html5lib: 1.0.1
sqlalchemy: 1.2.11
pymysql: None
psycopg2: 2.7.6.1 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

@jreback
Copy link
Contributor

jreback commented Dec 26, 2018

float16 has almost no support - PRs to improve this would be welcome

@WillAyd WillAyd added the Dtype Conversions Unexpected or buggy dtype conversions label Dec 27, 2018
@WillAyd WillAyd added this to the Contributions Welcome milestone Dec 27, 2018
@mikekutzma
Copy link
Contributor

I'll take a look at this

@WillAyd WillAyd added the Duplicate Report Duplicate issue or pull request label Dec 28, 2018
@WillAyd
Copy link
Member

WillAyd commented Dec 28, 2018

Thanks @mikekutzma. Closing this as a duplicate of #9220 however so please reference that PR in any changes

@WillAyd WillAyd closed this as completed Dec 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Duplicate Report Duplicate issue or pull request
Projects
None yet
Development

No branches or pull requests

4 participants