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

Int64 series resampling #25580

Closed
callumstew opened this issue Mar 7, 2019 · 0 comments

Comments

@callumstew
Copy link

commented Mar 7, 2019

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

sighingnow added a commit to sighingnow/pandas that referenced this issue Mar 7, 2019

Add IntegerArray.size, fix pandas-dev#25580.
Signed-off-by: HE, Tao <sighingnow@gmail.com>

sighingnow added a commit to sighingnow/pandas that referenced this issue Mar 7, 2019

Add IntegerArray.size, fix pandas-dev#25580.
Signed-off-by: HE, Tao <sighingnow@gmail.com>

@jreback jreback added this to the 0.24.2 milestone Mar 10, 2019

jorisvandenbossche added a commit that referenced this issue Mar 11, 2019

BUG: Redefine IndexOpsMixin.size, fix #25580. (#25584)
Signed-off-by: HE, Tao <sighingnow@gmail.com>

jorisvandenbossche added a commit to jorisvandenbossche/pandas that referenced this issue Mar 11, 2019

BUG: Redefine IndexOpsMixin.size, fix pandas-dev#25580. (pandas-dev#2…
…5584)

Signed-off-by: HE, Tao <sighingnow@gmail.com>
(cherry picked from commit 6375549)

thoo added a commit to thoo/pandas that referenced this issue Mar 11, 2019

Merge remote-tracking branch 'upstream/master' into pivot
* upstream/master: (110 commits)
  DOC: hardcode contributors for 0.24.x releases (pandas-dev#25662)
  DOC: restore toctree maxdepth (pandas-dev#25134)
  BUG: Redefine IndexOpsMixin.size, fix pandas-dev#25580. (pandas-dev#25584)
  BUG: to_csv line endings with compression (pandas-dev#25625)
  DOC: file obj for to_csv must be newline='' (pandas-dev#25624)
  Suppress incorrect warning in nargsort for timezone-aware DatetimeIndex (pandas-dev#25629)
  TST: fix incorrect sparse test (now failing on scipy master) (pandas-dev#25653)
  CLN: Removed debugging code (pandas-dev#25647)
  DOC: require Return section only if return is not None nor commentary (pandas-dev#25008)
  DOC:Remove hard-coded examples from _flex_doc_SERIES (pandas-dev#24589) (pandas-dev#25524)
  TST: xref pandas-dev#25630 (pandas-dev#25643)
  BUG: Fix pandas-dev#25481 by fixing the error message in TypeError (pandas-dev#25540)
  Fixturize tests/frame/test_mutate_columns.py (pandas-dev#25642)
  Fixturize tests/frame/test_join.py (pandas-dev#25639)
  Fixturize tests/frame/test_combine_concat.py (pandas-dev#25634)
  Fixturize tests/frame/test_asof.py (pandas-dev#25628)
  BUG: Fix user-facing AssertionError with to_html (pandas-dev#25608) (pandas-dev#25620)
  DOC: resolve all GL03 docstring validation errors (pandas-dev#25525)
  TST: failing wheel building on PY2 and old numpy (pandas-dev#25631)
  DOC: Remove makePanel from docs (pandas-dev#25609) (pandas-dev#25612)
  ...

jorisvandenbossche added a commit that referenced this issue Mar 11, 2019

BUG: Redefine IndexOpsMixin.size, fix #25580. (#25584) (#25667)
Signed-off-by: HE, Tao <sighingnow@gmail.com>
(cherry picked from commit 6375549)

hksonngan pushed a commit to hksonngan/pandas that referenced this issue Mar 12, 2019

hksonngan pushed a commit to hksonngan/pandas that referenced this issue Mar 12, 2019

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