Skip to content

ERR: Rolling().Apply() on Object-Series should raise internally caught errors #15085

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

Closed
floriangeigl opened this issue Jan 9, 2017 · 3 comments
Labels
Dtype Conversions Unexpected or buggy dtype conversions Error Reporting Incorrect or improved errors from pandas Reshaping Concat, Merge/Join, Stack/Unstack, Explode

Comments

@floriangeigl
Copy link

import pandas as pd
s = pd.Series([set([i]) for i in range(10)])
s.rolling(2).apply(lambda x: x[0] | x[1]) # just returns original series - lambda function gets never called)

.rolling().apply() on a object-series seems to do nothing. One can even write:

s.rolling(2).apply(lambda x: _non_existing_function_)

without getting an exception.

It would be great to get an exception if rolling().apply() can not be used with object-series or even better: A proper working rolling().apply() for object-series :)

The expected output from the rolling().apply() from above would be sth like:
NaN
{1,2}
{2,3}
{3,4}
...

or, as said before, at least an exception.

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.5.2.final.0 python-bits: 64 OS: Linux OS-release: 4.4.39-moby machine: x86_64 processor: byteorder: little LC_ALL: C.UTF-8 LANG: C.UTF-8 LOCALE: en_US.UTF-8

pandas: 0.19.2
nose: 1.3.7
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.24.1
numpy: 1.11.1
scipy: 0.18.1
statsmodels: 0.6.1
xarray: 0.8.2
IPython: 5.1.0
sphinx: 1.4.6
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.6.1
blosc: None
bottleneck: 1.1.0
tables: 3.2.3.1
numexpr: 2.6.1
matplotlib: 1.5.3
openpyxl: 2.3.2
xlrd: 1.0.0
xlwt: 1.1.2
xlsxwriter: 0.9.3
lxml: 3.6.4
bs4: 4.5.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: 2.6.2 (dt dec pq3 ext lo64)
jinja2: 2.8
boto: 2.42.0
pandas_datareader: None

@jreback
Copy link
Contributor

jreback commented Jan 9, 2017

the purpose of this is to allow a df.rolling(..).apply(...) to work on numeric columns and just return the other columns. So it has to ignore internal TypeErrors. I suppose it could raise for a Series though.

PR's are welcome.

@jreback jreback added Difficulty Intermediate Dtype Conversions Unexpected or buggy dtype conversions Error Reporting Incorrect or improved errors from pandas Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Jan 9, 2017
@jreback jreback added this to the Next Major Release milestone Jan 9, 2017
@jreback jreback changed the title Rolling().Apply() on Object-Series does nothing ERR: Rolling().Apply() on Object-Series should raise internally caught errors Jan 9, 2017
@ihsansecer
Copy link
Contributor

Raises DataError: No numeric types to aggregate on master (see #27044)

Rolling functions only work with numeric types for now. Related to #23002

@mroeschke
Copy link
Member

Right this properly raises a DataError on master. I think this was closed by #27044

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Error Reporting Incorrect or improved errors from pandas Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

No branches or pull requests

4 participants