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

pandas.rolling.max() shut down reopen #24218

Closed
kid3night opened this issue Dec 11, 2018 · 15 comments
Closed

pandas.rolling.max() shut down reopen #24218

kid3night opened this issue Dec 11, 2018 · 15 comments
Labels
Window rolling, ewma, expanding Windows Windows OS

Comments

@kid3night
Copy link

kid3night commented Dec 11, 2018

Code Sample, a copy-pastable example if possible

# Your code here
import pandas as pd

a = [0, 100900, 101000, 101000, 101000, 100900, 100900, 100900, 
	 100900, 100900, 100900, 100900, 100900, 100900, 100900, 
	 100900, 100900, 100900, 100900, 100900, 0, 100900, 100900, 
	 100900, 100900, 100900, 100900, 0, 0, 0, 101000, 0, 0, 0, 
	 101000, 100900, 100900, 100900, 100900, 100900, 100900, 
	 100900, 0, 101000, 101000, 101000, 101000, 0, 0, 0, 100900, 
	 100900, 100900, 100900, 100900, 100900, 100900, 100900, 
	 100900, 100900]

ix = pd.DatetimeIndex(['2018-06-01 09:33:49', '2018-06-01 09:33:50',
	               '2018-06-01 09:33:50', '2018-06-01 09:33:52',
	               '2018-06-01 09:33:52', '2018-06-01 09:33:53',
	               '2018-06-01 09:33:53', '2018-06-01 09:33:53',
	               '2018-06-01 09:33:53', '2018-06-01 09:33:53',
	               '2018-06-01 09:33:53', '2018-06-01 09:33:53',
	               '2018-06-01 09:33:53', '2018-06-01 09:33:53',
	               '2018-06-01 09:33:53', '2018-06-01 09:33:53',
	               '2018-06-01 09:33:53', '2018-06-01 09:33:53',
	               '2018-06-01 09:33:53', '2018-06-01 09:33:53',
	               '2018-06-01 09:33:53', '2018-06-01 09:33:53',
	               '2018-06-01 09:33:53', '2018-06-01 09:33:53',
	               '2018-06-01 09:33:53', '2018-06-01 09:33:53',
	               '2018-06-01 09:33:53', '2018-06-01 09:33:54',
	               '2018-06-01 09:33:54', '2018-06-01 09:33:54',
	               '2018-06-01 09:33:54', '2018-06-01 09:33:54',
	               '2018-06-01 09:33:55', '2018-06-01 09:33:55',
	               '2018-06-01 09:33:55', '2018-06-01 09:33:55',
	               '2018-06-01 09:33:55', '2018-06-01 09:33:55',
	               '2018-06-01 09:33:55', '2018-06-01 09:33:55',
	               '2018-06-01 09:33:55', '2018-06-01 09:33:55',
	               '2018-06-01 09:33:55', '2018-06-01 09:33:56',
	               '2018-06-01 09:33:56', '2018-06-01 09:33:56',
	               '2018-06-01 09:33:57', '2018-06-01 09:33:57',
	               '2018-06-01 09:33:57', '2018-06-01 09:33:57',
	               '2018-06-01 09:33:58', '2018-06-01 09:33:58',
	               '2018-06-01 09:33:58', '2018-06-01 09:33:58',
	               '2018-06-01 09:33:58', '2018-06-01 09:33:58',
	               '2018-06-01 09:33:58', '2018-06-01 09:33:58',
	               '2018-06-01 09:33:58', '2018-06-01 09:33:58'],
	              dtype='datetime64[ns]', name='0', freq=None)

series = pd.Series(a, index=ix)
series.rolling('3S', closed='left').max()

Problem description

I got a sample data and want to use it to get the rolling max, min, sum etc.
But every time I did rolling max/min on it, the python kernal would shut down and shows 'python.exe has stopped working'

Expected Output

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]

INSTALLED VERSIONS

commit: None
python: 3.6.5.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.23.0
pytest: 3.5.1
pip: 10.0.1
setuptools: 39.1.0
Cython: 0.28.2
numpy: 1.14.3
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 6.4.0
sphinx: 1.7.4
patsy: 0.5.0
dateutil: 2.7.3
pytz: 2018.4
blosc: None
bottleneck: 1.2.1
tables: 3.4.3
numexpr: 2.6.5
feather: None
matplotlib: 2.2.2
openpyxl: 2.5.3
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.0.4
lxml: 4.2.1
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: 1.2.7
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: 0.1.6
fastparquet: None
pandas_gbq: None
pandas_datareader: None

@WillAyd
Copy link
Member

WillAyd commented Dec 11, 2018

If you could make your code self-contained and copy/pastable would make it much easier for someone to take a look

@WillAyd WillAyd added the Needs Info Clarification about behavior needed to assess issue label Dec 11, 2018
@kid3night
Copy link
Author

If you could make your code self-contained and copy/pastable would make it much easier for someone to take a look

No problem, I have updated it.

@kid3night
Copy link
Author

If you could make your code self-contained and copy/pastable would make it much easier for someone to take a look

Is there any info needed right now?

@WillAyd
Copy link
Member

WillAyd commented Dec 14, 2018

Have you tried on master? IIRC we fixed something similar for windows recently

@kid3night
Copy link
Author

Have you tried on master? IIRC we fixed something similar for windows recently

I just updated and tried again. The problem still exist.

@WillAyd WillAyd added Can't Repro and removed Needs Info Clarification about behavior needed to assess issue labels Dec 14, 2018
@WillAyd
Copy link
Member

WillAyd commented Dec 14, 2018

Hmm I couldn't reproduce so likely a Windows issue. Let's see if someone else can

@kid3night
Copy link
Author

Hmm I couldn't reproduce so likely a Windows issue. Let's see if someone else can
Yea, I tried the same thing one my Mac and the problem doesn't exist.

@kid3night
Copy link
Author

Hmm I couldn't reproduce so likely a Windows issue. Let's see if someone else can

I want update one info:
If I use delete the closed='left', then the code will not crash. It seems that the problem exist in the boundary part.

@timhunderwood
Copy link
Contributor

Hello,

I was able to reproduce this on Windows.

From some debugging, the issue occurs when you get to:

pandas.core.window._Rolling#_apply

When it tries to call:

return cfunc(arg, window, minp, indexi, closed, **kwargs)

with cfunc refering to "roll_max".

I think something goes wrong in:
pandas._libs.window#_roll_min_max

I can reproduce the issue by running the below:

import pandas._libs.window
import numpy

values = numpy.linspace(0, 1, 5)
window = 2
minp = 1
index = numpy.array(range(5)).astype(numpy.int64)
closed = "left"

pandas._libs.window.roll_max(values, window, minp, index, closed)

The issue does not occur if closed="right" or closed="both" or closed=None.

Let me know if I can help debug/resolve.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.7.2.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
pandas: 0.23.4
pytest: None
pip: 18.1
setuptools: 40.6.3
Cython: None
numpy: 1.15.4
scipy: 1.2.0
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
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: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

@WillAyd
Copy link
Member

WillAyd commented Jan 5, 2019

@timhunderwood investigation and PRs are always welcome!

@WillAyd WillAyd added Windows Windows OS Window rolling, ewma, expanding and removed Can't Repro labels Jan 5, 2019
@WillAyd WillAyd added this to the Contributions Welcome milestone Jan 5, 2019
@timhunderwood
Copy link
Contributor

When I build version 0.24 locally ('0.24.0.dev0+1522.gd106e9975') this issue doesn't occur. Looks like it has already been fixed between 0.23.4 and now.

@jreback
Copy link
Contributor

jreback commented Jan 6, 2019

@timhunderwood you are running on windows? if want to put up a PR with a validation test (that cycles thru all of the closed options), would be great.

@timhunderwood
Copy link
Contributor

hi @jreback , yes, I am testing the above on windows. I will try and make a PR to test all the options for closed.

@timhunderwood
Copy link
Contributor

I had a look at pandas/tests/test_window.py - I think this issue is a duplicate of #21704 and was fixed in #21853. This PR also added pandas.tests.test_window.TestRolling#test_closed_min_max_datetime which tests all the combinations of closed and should cover the above case.

Hope that helps - let me know if you think there is something that should be added to those tests.

@jreback
Copy link
Contributor

jreback commented Jan 8, 2019

thanks

@jreback jreback closed this as completed Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Window rolling, ewma, expanding Windows Windows OS
Projects
None yet
Development

No branches or pull requests

4 participants