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

BUG: Rolling.mean downcasts extension dtypes #50399

Closed
2 of 3 tasks
bollard opened this issue Dec 22, 2022 · 5 comments
Closed
2 of 3 tasks

BUG: Rolling.mean downcasts extension dtypes #50399

bollard opened this issue Dec 22, 2022 · 5 comments
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@bollard
Copy link

bollard commented Dec 22, 2022

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

ser = pd.Series([i / 10 for i in range(1, 20)]).astype(pd.Float64Dtype())
ser.rolling(2).mean().dtype # dtype('float64')

Issue Description

#Rolling.mean prematurely downcast from extension-array type dtypes

Expected Behavior

That (in this example) the Float64Dtype is preserved

Installed Versions

INSTALLED VERSIONS

commit : 8dab54d
python : 3.10.8.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19044
machine : AMD64
processor : Intel64 Family 6 Model 165 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US.UTF-8
LOCALE : English_United Kingdom.1252

pandas : 1.5.2
numpy : 1.23.4
pytz : 2022.1
dateutil : 2.8.2
setuptools : 65.5.0
pip : 22.2.2
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.1
html5lib : None
pymysql : 1.0.2
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.6.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli :
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.5.3
numba : None
numexpr : None
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : 9.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : 1.4.39
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : None

@bollard bollard added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Dec 22, 2022
@phofl
Copy link
Member

phofl commented Dec 23, 2022

Hi, thanks for your report. This is already known and on our list. Rolling does not support extension arrays yet, hence we have to cast to numpy dtypes

@phofl phofl closed this as completed Dec 23, 2022
@bollard
Copy link
Author

bollard commented Dec 27, 2022

Ah understood, thanks. Is there anywhere I can track this?

@phofl
Copy link
Member

phofl commented Dec 27, 2022

Not sure, if we have an appropriate issue about this. If not, a tracker issue like ENH: Add masked support for rolling operations would be welcome

@bollard
Copy link
Author

bollard commented Dec 27, 2022

Done #50449. Thanks!

@phofl
Copy link
Member

phofl commented Dec 27, 2022

Thx, this is more helpful than a couple of different issues where every one of them lists a different method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

2 participants