Skip to content

Odd error message, concerning numpy using an alias versus numpy package name #28665

Closed
@apiszcz

Description

@apiszcz

This produces a poor warning

>>> import pandas as pd
>>> import numpy as np
>>> np.ptp(pd.Series([1, 2, 3]))
/lib/python3.7/site-packages/numpy/core/fromnumeric.py:2495: FutureWarning: Method .ptp is deprecated and will be removed in a future version. Use numpy.ptp instead.

because np.ptp calls Series.ptp, which is deprecated. We should instruct the user
to convert the Series to an array before calling ptp.

np.ptp(pd.Series([1, 2, 3]).array)

The warning is defined at

pandas/pandas/core/generic.py

Lines 10197 to 10199 in 20e4c18

warnings.warn(
"Method .ptp is deprecated and will be removed "
"in a future version. Use numpy.ptp instead.",


In this case I am using numpy ptp, however the error messages states I am not

>>> dfagg = df.groupby(['idf']).agg({ 'f1' : [np.min, np.max, np.ptp] })
C:\test\lib\numpy\core\fromnumeric.py:2495: FutureWarning: Method .ptp is deprecated and will be removed in a future version. Use numpy.ptp instead.

NO warning
>>> dfagg = df.groupby(['idf']).agg({ 'f1' : [np.min, np.max, numpy.ptp] })

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions