Repository: pandas-dev/pandas

Issue:
Int64 series resampling
#### Code Sample, a copy-pastable example if possible

```python
>>> 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. 
```python
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()``

<details>

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

</details>

Int64 series resampling
#### Code Sample, a copy-pastable example if possible

```python
>>> 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. 
```python
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()``

<details>

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

</details>



Discussion:

Resolving patch:
diff --git a/pandas/core/base.py b/pandas/core/base.py
--- a/pandas/core/base.py
+++ b/pandas/core/base.py
@@ -762,7 +762,7 @@ def size(self):
         """
         Return the number of elements in the underlying data.
         """
-        return self._values.size
+        return len(self._values)
 
     @property
     def flags(self):


Test patch:
diff --git a/pandas/tests/resample/test_datetime_index.py b/pandas/tests/resample/test_datetime_index.py
--- a/pandas/tests/resample/test_datetime_index.py
+++ b/pandas/tests/resample/test_datetime_index.py
@@ -101,6 +101,18 @@ def test_resample_basic(series, closed, expected):
     assert_series_equal(result, expected)
 
 
+def test_resample_integerarray():
+    # GH 25580, resample on IntegerArray
+    ts = pd.Series(range(9),
+                   index=pd.date_range('1/1/2000', periods=9, freq='T'),
+                   dtype='Int64')
+    result = ts.resample('3T').sum()
+    expected = Series([3, 12, 21],
+                      index=pd.date_range('1/1/2000', periods=3, freq='3T'),
+                      dtype="Int64")
+    assert_series_equal(result, expected)
+
+
 def test_resample_basic_grouper(series):
     s = series
     result = s.resample('5Min').last()
diff --git a/pandas/tests/series/test_api.py b/pandas/tests/series/test_api.py
--- a/pandas/tests/series/test_api.py
+++ b/pandas/tests/series/test_api.py
@@ -493,6 +493,13 @@ def test_tab_complete_warning(self, ip):
             with provisionalcompleter('ignore'):
                 list(ip.Completer.completions('s.', 1))
 
+    def test_integer_series_size(self):
+        # GH 25580
+        s = Series(range(9))
+        assert s.size == 9
+        s = Series(range(9), dtype="Int64")
+        assert s.size == 9
+
 
 class TestCategoricalSeries(object):