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

Keep Rolling operations result at float32 #24224

Closed
erdnaavlis opened this issue Dec 11, 2018 · 3 comments
Closed

Keep Rolling operations result at float32 #24224

erdnaavlis opened this issue Dec 11, 2018 · 3 comments
Labels
Duplicate Report Duplicate issue or pull request Window rolling, ewma, expanding

Comments

@erdnaavlis
Copy link

Code Sample

my_series = pd.Series([1,2,3,4,5,6,7,8,9]).astype(np.float32)
my_series

0 1.0
1 2.0
2 3.0
3 4.0
4 5.0
5 6.0
6 7.0
7 8.0
8 9.0
dtype: float32

my_series.rolling(3).sum()

0 NaN
1 NaN
2 6.0
3 9.0
4 12.0
5 15.0
6 18.0
7 21.0
8 24.0
dtype: float64

Problem description

In working with big amounts of data that do not require the higher precision of float64, I tend to use float32. This improves both storage and computation time.

Similarly I would like for all the calculation with such data to be done in float32. The example above shows that rolling operations always return float64 regardless of the type of the input. Is it possible to force rolling calculations at float32?

INSTALLED VERSIONS

commit: None
python: 3.7.1.final.0
python-bits: 64
OS: Darwin
OS-release: 18.2.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: pt_PT.UTF-8
LOCALE: pt_PT.UTF-8

pandas: 0.23.4
pytest: 4.0.1
pip: 18.1
setuptools: 40.6.2
Cython: None
numpy: 1.15.4
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 7.2.0
sphinx: None
patsy: 0.5.1
dateutil: 2.7.5
pytz: 2018.7
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

@jreback
Copy link
Contributor

jreback commented Dec 11, 2018

pls search the issues - this is a duplicate issue

@erdnaavlis
Copy link
Author

@jreback I couldn't find a duplicate of this issue. I've found #15599 which maybe has the same root cause as this issue. But I understand the reasoning behind casting from int to float if we want to do, say, a rolling mean.

In my example, I would like to use and keep the result at float32. That's why I opened this one.

But if you still think this is a duplicate I can close this one. Just let me know.

@WillAyd
Copy link
Member

WillAyd commented Dec 12, 2018

I believe the original issue is #11446 - contributions to improve type management would certainly be welcome

@WillAyd WillAyd added Duplicate Report Duplicate issue or pull request Window rolling, ewma, expanding labels Dec 12, 2018
@WillAyd WillAyd closed this as completed Dec 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request Window rolling, ewma, expanding
Projects
None yet
Development

No branches or pull requests

3 participants