pandas 1.4.2

NotesReturns
abs(self: 'NDFrameT') -> 'NDFrameT'

This function only applies to elements that are all numeric.

Notes

For complex inputs, 1.2 + 1j , the absolute value is $\sqrt{ a^2 + b^2 }$ .

Returns

abs

Series/DataFrame containing the absolute value of each element.

Return a Series/DataFrame with absolute numeric value of each element.

See Also

numpy.absolute

Calculate the absolute value element-wise.

Examples

Absolute numeric values in a Series.

This example is valid syntax, but we were not able to check execution
>>> s = pd.Series([-1.10, 2, -3.33, 4])
... s.abs() 0 1.10 1 2.00 2 3.33 3 4.00 dtype: float64

Absolute numeric values in a Series with complex numbers.

This example is valid syntax, but we were not able to check execution
>>> s = pd.Series([1.2 + 1j])
... s.abs() 0 1.56205 dtype: float64

Absolute numeric values in a Series with a Timedelta element.

This example is valid syntax, but we were not able to check execution
>>> s = pd.Series([pd.Timedelta('1 days')])
... s.abs() 0 1 days dtype: timedelta64[ns]

Select rows with data closest to certain value using argsort (from StackOverflow).

This example is valid syntax, but we were not able to check execution
>>> df = pd.DataFrame({
...  'a': [4, 5, 6, 7],
...  'b': [10, 20, 30, 40],
...  'c': [100, 50, -30, -50]
... })
... df a b c 0 4 10 100 1 5 20 50 2 6 30 -30 3 7 40 -50
This example is valid syntax, but we were not able to check execution
>>> df.loc[(df.c - 43).abs().argsort()]
     a    b    c
1    5   20   50
0    4   10  100
2    6   30  -30
3    7   40  -50
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/generic.py#1579
type: <class 'function'>
Commit: