pandas
pandas copied to clipboard
docs: update `freq` description for `pd.Timedelta.ceil` to match `DatetimeIndex.ceil`'s `freq` description
Pandas version checks
-
[X] I have checked that this issue has not already been reported.
-
[X] 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 : 0691c5cf90477d3503834d983f69350f250a6ff7 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