-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
Code Sample, a copy-pastable example if possible
from pandas.tseries.offsets import MonthBegin
MonthBegin(normalize=True).rollback('2020-4-1 12:34')
Out[2]: Timestamp('2020-03-01 00:00:00')
Problem description
It rollbacks to the beginning of the previous month instead of the current month. This happens only when normalize=True and the timestamp is within the first day of the month but strangely, it's correct for midnight:
from pandas.tseries.offsets import MonthBegin
MonthBegin(normalize=True).rollback('2020-4-1 00:00')
Out[3]: Timestamp('2020-04-01 00:00:00')
Expected Output
Out[2]: Timestamp('2020-04-01 00:00:00')
In general, I would expect the following to hold for any timestamp dt
:
assert MonthBegin(normalize=True).rollback(dt) == MonthBegin().rollback(dt.normalize())
Output of pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.6.8.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 78 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
pandas : 1.0.1
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 40.6.2
Cython : 0.29.4
pytest : 5.3.5
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 1.2.8
lxml.etree : 4.5.0
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.1
IPython : 7.13.0
pandas_datareader: None
bs4 : 4.6.1
bottleneck : 1.3.1
fastparquet : None
gcsfs : None
lxml.etree : 4.5.0
matplotlib : 3.2.0
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.3
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.3.5
pyxlsb : None
s3fs : 0.2.1
scipy : 1.4.1
sqlalchemy : 1.3.13
tables : None
tabulate : 0.8.6
xarray : 0.15.0
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : 1.2.8
numba : None