@@ -7603,12 +7603,70 @@ def _tz_localize(ax, tz, ambiguous):
76037603 # Numeric Methods
76047604 def abs (self ):
76057605 """
7606- Return an object with absolute value taken--only applicable to objects
7607- that are all numeric.
7606+ Return a Series/DataFrame with absolute numeric value of each element.
7607+
7608+ This function only applies to elements that are all numeric.
76087609
76097610 Returns
76107611 -------
7611- abs: type of caller
7612+ abs
7613+ Series/DataFrame containing the absolute value of each element.
7614+
7615+ Notes
7616+ -----
7617+ For ``complex`` inputs, ``1.2 + 1j``, the absolute value is
7618+ :math:`\\ sqrt{ a^2 + b^2 }`.
7619+
7620+ Examples
7621+ --------
7622+ Absolute numeric values in a Series.
7623+
7624+ >>> s = pd.Series([-1.10, 2, -3.33, 4])
7625+ >>> s.abs()
7626+ 0 1.10
7627+ 1 2.00
7628+ 2 3.33
7629+ 3 4.00
7630+ dtype: float64
7631+
7632+ Absolute numeric values in a Series with complex numbers.
7633+
7634+ >>> s = pd.Series([1.2 + 1j])
7635+ >>> s.abs()
7636+ 0 1.56205
7637+ dtype: float64
7638+
7639+ Absolute numeric values in a Series with a Timedelta element.
7640+
7641+ >>> s = pd.Series([pd.Timedelta('1 days')])
7642+ >>> s.abs()
7643+ 0 1 days
7644+ dtype: timedelta64[ns]
7645+
7646+ Select rows with data closest to certian value using argsort (from
7647+ `StackOverflow <https://stackoverflow.com/a/17758115>`__).
7648+
7649+ >>> df = pd.DataFrame({
7650+ ... 'a': [4, 5, 6, 7],
7651+ ... 'b': [10, 20, 30, 40],
7652+ ... 'c': [100, 50, -30, -50]
7653+ ... })
7654+ >>> df
7655+ a b c
7656+ 0 4 10 100
7657+ 1 5 20 50
7658+ 2 6 30 -30
7659+ 3 7 40 -50
7660+ >>> df.loc[(df.c - 43).abs().argsort()]
7661+ a b c
7662+ 1 5 20 50
7663+ 0 4 10 100
7664+ 2 6 30 -30
7665+ 3 7 40 -50
7666+
7667+ See Also
7668+ --------
7669+ numpy.absolute : calculate the absolute value element-wise.
76127670 """
76137671 return np .abs (self )
76147672
0 commit comments