pandas.DataFrame.abs() function with example in python
pandas.DataFrame.abs(): This function return a Series/DataFrame with absolute numeric value of each element.
This function only applies to elements that are all numeric.
Returns:
abs
Series/DataFrame containing the absolute value of each element.
import pandas as pd
df = pd.DataFrame({ 'x': [4, 5, -6, 7], 'y': [-5,-6,7,10]})
df1= df.abs()
print(df1)
Output:
x y 0 4 5 1 5 6 2 6 7 3 7 10