Skip to content

docs: update freq description for pd.Timedelta.ceil to match DatetimeIndex.ceil's freq description #59902

Closed
@robert-nash

Description

@robert-nash

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

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions