Description
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
data = [0,1,2,3,4,5,6,7,8,9,10,11]
index = pd.date_range(
pd.Timestamp("2000-01-01"),
pd.Timestamp("2000-01-01") + pd.Timedelta(minutes=3),
freq='16S',
)
s = pd.Series(data,index)
s.resample('T').ohlc()
Issue Description
open high low close
2000-01-01 00:00:00 0 3 0 3
2000-01-01 00:01:00 4 7 4 7
2000-01-01 00:02:00 8 11 8 11
The open values for the second and third values are from the future:
2000-01-01 00:01:04 4
and 2000-01-01 00:02:08 8
Expected Behavior
The output should be:
open high low close
2000-01-01 00:00:00 0 3 0 3
2000-01-01 00:01:00 3 7 4 7
2000-01-01 00:02:00 7 11 8 11
For all but the first open value the previous close value should be used
Installed Versions
INSTALLED VERSIONS
commit : 37ea63d
python : 3.10.11.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-148-generic
Version : #165-Ubuntu SMP Tue Apr 18 08:53:12 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8
pandas : 2.0.1
numpy : 1.24.3
pytz : 2023.3
dateutil : 2.8.2
setuptools : 67.7.2
pip : 23.1.2
Cython : None
pytest : None
hypothesis : None
sphinx : 7.0.1
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.2
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.13.2
pandas_datareader: None
bs4 : 4.12.2
bottleneck : None
brotli :
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.7.1
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.10.1
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : 2.3.1
pyqt5 : None