Skip to content

'closed' parameter is not working for Rolling with duplicate Timestamp #23335

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
jiehuan opened this issue Oct 25, 2018 · 4 comments
Closed

'closed' parameter is not working for Rolling with duplicate Timestamp #23335

jiehuan opened this issue Oct 25, 2018 · 4 comments
Labels
Bug Window rolling, ewma, expanding

Comments

@jiehuan
Copy link

jiehuan commented Oct 25, 2018

The 'closed' parameter is not really working when the date is duplicated.

Here is an example.

import pandas as pd

df = pd.DataFrame({'Date': ['2016-06-30', '2016-06-30', '2016-08-09'],
                   'amount': [100, 200, 10]
                  })

df['Date'] = pd.to_datetime(df['Date'])

df
Data amount
0 2016-06-30 100
1 2016-06-30 200
2 2016-08-09 10
df.rolling(window='90d', on='Date', closed='neither').sum()

Output

Data amount
0 2016-06-30 NaN
1 2016-06-30 100
2 2016-08-09 300

Expected output:

Data amount
0 2016-06-30 NaN
1 2016-06-30 NaN
2 2016-08-09 300

Output of pd.show_versions()

show_version

INSTALLED VERSIONS

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

pandas: 0.23.4
pytest: None
pip: 18.1
setuptools: 40.4.3
Cython: None
numpy: 1.15.2
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 7.0.1
sphinx: None
patsy: None
dateutil: 2.7.3
pytz: 2018.5
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 3.0.0
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

@TomAugspurger
Copy link
Contributor

Could you update your example to be reproducible (steps to crate the dataframe, execute the problematic method)? http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports

And include the output of show_versions in a details tag.

@gfyoung gfyoung added Datetime Datetime data dtype Can't Repro Window rolling, ewma, expanding Needs Info Clarification about behavior needed to assess issue and removed Can't Repro labels Oct 26, 2018
@jiehuan
Copy link
Author

jiehuan commented Oct 26, 2018

updated. Thanks!

@TomAugspurger TomAugspurger removed the Needs Info Clarification about behavior needed to assess issue label Oct 26, 2018
@TomAugspurger
Copy link
Contributor

Thanks. It's not immediately clear to me what's going on here. If you're able to do any additional debugging, it'd be appreciated. It's probably an issue somewhere in pandas/core/window.py, or (more likely) in pandas/_libs/window.pyx.

@mroeschke
Copy link
Member

Closing as a duplicate of #20712

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Window rolling, ewma, expanding
Projects
None yet
Development

No branches or pull requests

4 participants