Skip to content

BUG: "RuntimeWarning: divide by zero encountered in log10" that does not appear with a numpy argument #46473

Open
@bersbersbers

Description

@bersbersbers

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 numpy as np, pandas as pd
x = np.array([0.0, 1.0])
df = pd.DataFrame(x, columns=["x"])
np.log10(x, out=np.zeros_like(x), where=x>0)     # no warning, expected result ([0, 0])
np.log10(df.x, where=x>0)                        # no warning, usually incorrect result
np.log10(df.x, out=np.zeros_like(x), where=x>0)  # warning, correct result

Issue Description

Warning:

Python\Python310\lib\site-packages\pandas\core\arraylike.py:397: RuntimeWarning: divide by zero encountered in log10
result = getattr(ufunc, method)(*inputs, **kwargs)

Expected Behavior

No warning

Installed Versions

(show_versions() fails with assert '_distutils' in core.file, core.file)

Pandas 1.4.1 from pip and pandas-1.5.0.dev0+583.g5414a2d59 from GitHub

Metadata

Metadata

Assignees

Labels

BugWarningsWarnings that appear or should be added to pandasufuncs__array_ufunc__ and __array_function__

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions