Int64 series resampling · Issue #25580 · pandas-dev/pandas (original) (raw)

Code Sample, a copy-pastable example if possible

import pandas as pd index = pd.date_range('1/1/2000', periods=9, freq='T') series = pd.Series(range(9), index=index, dtype='Int64')
series.resample('3T').sum()

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

Problem description

Pandas series with an Int64 dtype can not be resampled, instead raising an AttributeError because they have no size method. If the series is accessed as part of a DataFrame, e.g. 'df.resample('3T').series.mean()', it is successful.
It can also be fixed by adding a 'size' method to the IntegerArray class, e.g.

def size(self): return self._data.size()

Expected Output

2000-01-01 00:00:00 1
2000-01-01 00:03:00 4
2000-01-01 00:06:00 7
Freq: 3T, dtype: Int64

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.7.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-43-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.24.1
pytest: 4.1.1
pip: 18.1
setuptools: 40.2.0
Cython: 0.29.2
numpy: 1.16.1
scipy: 1.2.1
pyarrow: None
xarray: None
IPython: 6.5.0
sphinx: 1.8.3
patsy: 0.5.1
dateutil: 2.7.3
pytz: 2018.5
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.2.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: None
bs4: None
html5lib: 1.0.1
sqlalchemy: 1.2.15
pymysql: None
psycopg2: 2.7.7 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: 0.2.0
fastparquet: 0.1.6
pandas_gbq: None
pandas_datareader: None
gcsfs: None