Skip to content

BUG: TimedeltaIndex.__rfloordiv__ triggers ZeroDivisionError when other is a list but works for scalar #54554

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

Open
2 of 3 tasks
twoertwein opened this issue Aug 15, 2023 · 0 comments
Labels
Bug Index Related to the Index class or subclasses Numeric Operations Arithmetic, Comparison, and Logical operations Timedelta Timedelta data type

Comments

@twoertwein
Copy link
Member

twoertwein commented Aug 15, 2023

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 
import datetime

index = pd.Index([pd.Timedelta(1)], dtype="timedelta64[s]")
delta = datetime.timedelta(1)

# floordiv
index // delta # works, 0 (dtype: int64)
index // [delta] # works, 0 (dtype: object!)
delta // index # works, 0 (dtype (int64))
[delta] // index # ZeroDivisionError

# truediv
index / delta # works, 0.0 (dtype: float64)
index / [delta] # works, 0.0 (dtype: object!)
delta / index # works, inf! (dtype: float64)
[delta] / index # ZeroDivisionError

Issue Description

I would expect the same behavior in the above two examples.

edit: and the dtype and the result should be the same (see object and inf)

Expected Behavior

Scalar works, but it raises with the same scalar in a list.

xref pandas-dev/pandas-stubs#764

Installed Versions

/var/home/twoertwein/.cache/pypoetry/virtualenvs/pandas-stubs-DrIM1v70-py3.11/lib/python3.11/site-packages/_distutils_hack/__init__.py:33: UserWarning: Setuptools is replacing distutils. warnings.warn("Setuptools is replacing distutils.")

INSTALLED VERSIONS

commit : 0f43794
python : 3.11.4.final.0
python-bits : 64
OS : Linux
OS-release : 6.4.7-200.fc38.x86_64
Version : #1 SMP PREEMPT_DYNAMIC Thu Jul 27 20:01:18 UTC 2023
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.0.3
numpy : 1.25.2
pytz : 2023.3
dateutil : 2.8.2
setuptools : 68.0.0
pip : 23.0.1
Cython : 3.0.0
pytest : 7.4.0
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 3.1.2
lxml.etree : 4.9.3
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : 2023.6.0
gcsfs : None
matplotlib : 3.7.2
numba : None
numexpr : 2.8.4
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : 12.0.1
pyreadstat : 1.2.2
pyxlsb : 1.0.10
s3fs : None
scipy : 1.9.3
snappy : None
sqlalchemy : 2.0.19
tables : 3.8.0
tabulate : 0.9.0
xarray : 2023.1.0
xlrd : 2.0.1
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

@twoertwein twoertwein added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 15, 2023
@twoertwein twoertwein changed the title BUG: TimedeltaIndex.__floordiv__ triggers ZeroDivisionError when other is a list but works for scalar BUG: TimedeltaIndex.__rfloordiv__ triggers ZeroDivisionError when other is a list but works for scalar Aug 15, 2023
@lithomas1 lithomas1 added Timedelta Timedelta data type Index Related to the Index class or subclasses and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 16, 2023
@jbrockmendel jbrockmendel added the Numeric Operations Arithmetic, Comparison, and Logical operations label Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Index Related to the Index class or subclasses Numeric Operations Arithmetic, Comparison, and Logical operations Timedelta Timedelta data type
Projects
None yet
Development

No branches or pull requests

3 participants