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

Standard Error of the Mean Unavailable in RollingGroupby #26476

Closed
blalterman opened this issue May 20, 2019 · 0 comments · Fixed by #37043
Closed

Standard Error of the Mean Unavailable in RollingGroupby #26476

blalterman opened this issue May 20, 2019 · 0 comments · Fixed by #37043
Labels
Enhancement Window rolling, ewma, expanding
Milestone

Comments

@blalterman
Copy link

Code Sample, a copy-pastable example if possible

Standard Error of the Mean works on Groupby objects, but not RollingGroupby objects.

Groupby object

data = pd.DataFrame({"a": np.linspace(0, 100, 101), 
                                       "b": np.random.random(101).round(1) # values we can group on
                                      })

# print values to 2 decimal places. Just showing it works.
data.groupby("b").sem().T.round(2)

Problem description

RollingGroupby object raises AttributeError

data = pd.DataFrame({"a": np.linspace(0, 100, 101), 
                                       "b": np.random.random(101).round(1) # values we can group on
                                      })

# print values to 2 decimal places. Just showing it works.
data.rolling(5).sem()

I believe API of Groupby and RollingGroupby are supposed to be as similar as possible. Than an optomized aggregation is available in one, but not the other is a problem.

Expected Output

The output should be the equivalent of

>>> data.rolling(5).std() / (data.rolling(5).count() - ddof).pow(0.5)

where ddof is degrees of freedom.

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.7.3.final.0 python-bits: 64 OS: Linux OS-release: 3.10.0-693.11.6.el7.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8

pandas: 0.24.2
pytest: 4.4.1
pip: 19.0.3
setuptools: 41.0.0
Cython: None
numpy: 1.16.3
scipy: 1.2.1
pyarrow: None
xarray: None
IPython: 7.4.0
sphinx: 2.0.1
patsy: None
dateutil: 2.8.0
pytz: 2019.1
blosc: None
bottleneck: 1.2.1
tables: 3.5.1
numexpr: 2.6.9
feather: None
matplotlib: 3.0.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10.1
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

@jbrockmendel jbrockmendel added the Window rolling, ewma, expanding label Oct 16, 2019
@jreback jreback added this to the 1.2 milestone Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Window rolling, ewma, expanding
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants