Series.ptp()
Pandas Series.ptp()
returns the difference between the maximum value and
the minimum value in the object. This is the equivalent of the numpy.ndarray
ptp
method.
Syntax: Series.ptp (axis = None, skipna = None, level = None, numeric_only = None, ** kwargs)
Parameter:
axis: Axis for the function to be applied on.
skipna: Exclude NA / null values when computing the result.
level: If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a scalar.
numeric_only: Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data. Not implemented for Series.
** kwargs: Additional keyword arguments to be passed to the function.Returns: ptp: scalar or Series (if level specified)
Example # 1: Use Series.ptp ()
to return the difference between the maximum and minimum baseline values data in this Series object.

Output:
Now we will use Series.ptp ()
to find the difference between the maximum and minimum values in a given series object.

Output:
As we can see in the output, Series.ptp ()
successfully returned the difference between the maximum and minimum values of the underlying data in this Series object.
Example # 2: Use Series.ptp ()
to return the difference between the maximum and minimum values of the underlying data in a given Series object .
Output:
Now we will use Series.ptp ()
to find the difference between maxim the minimum and minimum value in this series object.


Output:
As we can see in the output, Series.ptp ()
successfully returned the difference between the maximum and minimum values of the underlying data in the given series object.
Example # 3: Use Series.ptp ()
to return the difference between the maximum and minimum values of the underlying data in this Series object. This series object contains some missing values.

Output:
We will now use Series.ptp ()
to find the difference between the maximum and the minimum value in the given object of the series. we’re going to skip missing values in the calculation.

Output:
As we see on output, Series.ptp ()
successfully returned the difference between the maximum and minimum values of the underlying data in the given series object. < / p>