pandas-dev / pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
https://pandas.pydata.org
BSD 3-Clause "New" or "Revised" License
43.53k stars 17.88k forks source link

BUG: pandas.tseries.offsets.Second() division #57264

Open famenzel opened 8 months ago

famenzel commented 8 months ago

Pandas version checks

Reproducible Example

import pandas.tseries.offsets as tso
a = tso.Second()/10
b = tso.Second()*.1

Issue Description

In contrast to tso.Minute(), tso.Day(), division with tso.Second() with any integer always results in tso.Day(0) (a). This is not the case with the corresponding multiplication (b). In previous pandas versions this did not happen.

Expected Behavior

tso.Second()/10 should return tso.Milli(100) and not tso.Day(0).

Installed Versions

INSTALLED VERSIONS ------------------ commit : f538741432edf55c6b9fb5d0d496d2dd1d7c2457 python : 3.10.11.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.22621 machine : AMD64 processor : Intel64 Family 6 Model 154 Stepping 4, GenuineIntel byteorder : little LC_ALL : None LANG : de_DE.UTF-8 LOCALE : de_DE.cp1252 pandas : 2.2.0 numpy : 1.25.2 pytz : 2023.3.post1 dateutil : 2.8.2 setuptools : 65.5.0 pip : 23.0.1 Cython : None pytest : 7.4.0 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.2 IPython : 8.14.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : None bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : None gcsfs : None matplotlib : 3.7.3 numba : 0.58.0 numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : 1.11.3 sqlalchemy : 2.0.19 tables : None tabulate : 0.9.0 xarray : None xlrd : None zstandard : None tzdata : 2023.3 qtpy : None pyqt5 : None
rhshadrach commented 8 months ago

Thanks for the report. Result of a git bisect:

commit 8b8f0d04795e80a9298688e55bb4164b597392bc
Author: jbrockmendel
Date:   Tue Dec 19 15:35:22 2023 -0800

    DEPR: Tick.delta (#56558)

cc @jbrockmendel

lithomas1 commented 8 months ago

Looks like the difference is with the _value attr on Timedelta

>>> pd.Timedelta(a)._value
1
>>> a.delta._value
<stdin>:1: FutureWarning: Second.delta is deprecated and will be removed in a future version. Use pd.Timedelta(obj) instead
1000000000

Taking a look