-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
regression in 0.24: np.clip does not work for some values of a_min #25066
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
Comments
@sam-s @jorisvandenbossche : I tracked down the regression, and it boils down to this: When tiny floats and integers are involved in In Relevant files: |
Reading the docs, this rounding / downcasting behavior is not documented in the docstring for
Thoughts? cc @jreback |
Pushing to 0.24.2, since this looks a little tricky.. |
@gfyoung I didn't look into detail, but from your explanation, I was thinking: couldn't we check the type of the scalar clip value? If the clipping value you provide is a float, then I would say it is OK that the output is also float (even if your original column was int). On the other hand, long term, we could also try to go to a behaviour where we always preserve the dtype (basically meaning we would cast the clip value to the dtype of the column, so any float clip value would be converted to int). So if you want to clip integers with a clip value like 0.5, you first need to cast them to floats. |
Although, argument against it: numpy doesn't do this. (but numpy does always result in a dtype compatible with the clipping values) |
Code Sample
Problem description
With pandas
0.23.4
,numpy.clip
works as expected, producing aSeries
of typefloat64
for anymin
argument.With pandas
0.24.0
, it works up to 1e-7 but not for 1e-8This is an unwelcome change from the previous version.
Expected Output
Output of
pd.show_versions()
pandas: 0.24.0
pytest: None
pip: 19.0.1
setuptools: 40.7.0
Cython: None
numpy: 1.16.0
scipy: 1.2.0
pyarrow: None
xarray: None
IPython: 7.2.0
sphinx: None
patsy: None
dateutil: 2.7.5
pytz: 2018.9
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 3.0.2
openpyxl: None
xlrd: 1.2.0
xlwt: None
xlsxwriter: 1.1.2
lxml.etree: 4.3.0
bs4: None
html5lib: None
sqlalchemy: 1.2.17
pymysql: None
psycopg2: 2.7.7 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None
The text was updated successfully, but these errors were encountered: