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

BUG: Timedelta.ceil throws error when used with "m" unit #59902

Open
2 of 3 tasks
robert-nash opened this issue Sep 26, 2024 · 1 comment
Open
2 of 3 tasks

BUG: Timedelta.ceil throws error when used with "m" unit #59902

robert-nash opened this issue Sep 26, 2024 · 1 comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@robert-nash
Copy link

robert-nash commented Sep 26, 2024

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
td = pd.Timedelta('1001ms')
td.ceil("s")
td.ceil("min")
td.ceil("m")

Issue Description

Calling td.ceil("m") causes the error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "timedeltas.pyx", line 2011, in pandas._libs.tslibs.timedeltas.Timedelta.ceil
  File "timedeltas.pyx", line 1934, in pandas._libs.tslibs.timedeltas.Timedelta._round
  File "timedeltas.pyx", line 2309, in pandas._libs.tslibs.timedeltas.get_unit_for_round
  File "offsets.pyx", line 756, in pandas._libs.tslibs.offsets.BaseOffset.nanos.__get__
ValueError: <MonthEnd> is a non-fixed frequency

Expected Behavior

td.ceil("m") should behave the same as td.ceil("min")

The documentation for pandas.Timedelta.ceil states that the freq parameter uses the same units as class constructor Timedelta.

The documentation for pandas.Timedelta lists (‘minutes’, ‘minute’, ‘min’, or ‘m’) as one of the possible value lines. This suggests to me that "min" and "m" are equivalent.

It seems that either the documentation could be clearer or there is a bug?

Installed Versions

INSTALLED VERSIONS

commit : 0691c5c
python : 3.12.4
python-bits : 64
OS : Windows
OS-release : 11
Version : 10.0.22631
machine : AMD64
processor : Intel64 Family 6 Model 154 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : English_United Kingdom.1252

pandas : 2.2.3
numpy : 2.0.1
pytz : 2024.2
dateutil : 2.9.0.post0
pip : 24.1
Cython : None
sphinx : None
IPython : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.4
lxml.etree : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : None
pyreadstat : None
pytest : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.14.0
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2024.2
qtpy : None
pyqt5 : None

@robert-nash robert-nash added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 26, 2024
@nicholasyfu1
Copy link

I can work on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

2 participants