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: astype('Int64') raises AttributeError #22578

Closed
jorisvandenbossche opened this issue Sep 3, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@jorisvandenbossche
Copy link
Member

commented Sep 3, 2018

In [8]: df = pd.DataFrame([[1., 2.], [3., 4.], [5., 6.]], columns=['a', 'b'])

In [9]: df
Out[9]: 
     a    b
0  1.0  2.0
1  3.0  4.0
2  5.0  6.0

In [10]: df.astype('Int64')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-10-b9d2763e69d8> in <module>()
----> 1 df.astype('Int64')

~/scipy/pandas/pandas/util/_decorators.py in wrapper(*args, **kwargs)
    175                 else:
    176                     kwargs[new_arg_name] = new_arg_value
--> 177             return func(*args, **kwargs)
    178         return wrapper
    179     return _deprecate_kwarg

~/scipy/pandas/pandas/core/generic.py in astype(self, dtype, copy, errors, **kwargs)
   5162             # else, only a single dtype is given
   5163             new_data = self._data.astype(dtype=dtype, copy=copy, errors=errors,
-> 5164                                          **kwargs)
   5165             return self._constructor(new_data).__finalize__(self)
   5166 

~/scipy/pandas/pandas/core/internals/managers.py in astype(self, dtype, **kwargs)
    554 
    555     def astype(self, dtype, **kwargs):
--> 556         return self.apply('astype', dtype=dtype, **kwargs)
    557 
    558     def convert(self, **kwargs):

~/scipy/pandas/pandas/core/internals/managers.py in apply(self, f, axes, filter, do_integrity_check, consolidate, **kwargs)
    421 
    422             kwargs['mgr'] = self
--> 423             applied = getattr(b, f)(**kwargs)
    424             result_blocks = _extend_blocks(applied, result_blocks)
    425 

~/scipy/pandas/pandas/core/internals/blocks.py in astype(self, dtype, copy, errors, values, **kwargs)
    562     def astype(self, dtype, copy=False, errors='raise', values=None, **kwargs):
    563         return self._astype(dtype, copy=copy, errors=errors, values=values,
--> 564                             **kwargs)
    565 
    566     def _astype(self, dtype, copy=False, errors='raise', values=None,

~/scipy/pandas/pandas/core/internals/blocks.py in _astype(self, dtype, copy, errors, values, klass, mgr, **kwargs)
    679                     "current ({newb_dtype} [{newb_size}])".format(
    680                         copy=copy, dtype=self.dtype.name,
--> 681                         itemsize=self.itemsize, newb_dtype=newb.dtype.name,
    682                         newb_size=newb.itemsize))
    683         return newb

AttributeError: 'FloatBlock' object has no attribute 'itemsize'

The same if the starting dataframe is of integer dtype.

@sinhrks sinhrks referenced this issue Sep 28, 2018

Merged

BUG: astype(Int64) raises AttributeError #22869

3 of 3 tasks complete

@jreback jreback added this to the 0.24.0 milestone Sep 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.