Skip to content

'IntegerArray' object has no attribute 'T' #32342

Closed
@bnaul

Description

@bnaul

In our case this arose via .cumsum():

pd.Series([0, 1], dtype='int64').cumsum()
0    0
1    1
dtype: int64

pd.Series([0, 1], dtype='Int64').cumsum()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-31-2ebc3e3cf698> in <module>
----> 1 pd.Series([0, 1], dtype='Int64').cumsum()
...

~/model/.venv/lib/python3.7/site-packages/pandas/core/generic.py in na_accum_func(blk_values)
  11324                 np.putmask(result, mask, mask_b)
  11325             else:
> 11326                 result = accum_func(blk_values.T, axis)
  11327
  11328             # transpose back for ndarray, not for EA

AttributeError: 'IntegerArray' object has no attribute 'T'

But it's also true that just calling .values.T on a regular int array works (just a no-op), whereas on an Int64 array it does not. Same is true for

Any reason not to just add a no-op .T on the base ExtensionArray class..? cc @TomAugspurger in case you have an opinion 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExtensionArrayExtending pandas with custom dtypes or arrays.Needs TestsUnit test(s) needed to prevent regressions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions