Get the absolute values in Pandas Improve Improve Like Article Like Save Share Report Let us see how to get the absolute value of an element in Python Pandas. We can perform this task by using the abs() function. The abs() function is used to get a Series/DataFrame with absolute numeric value of each element. Syntax : Series.abs() or DataFrame.abs() Parameters : None Returns : Series/DataFrame containing the absolute value of each element. Example 1 : Absolute numeric values in a Series. # import the library import pandas as pd # create the Series s = pd.Series([-2.8, 3, -4.44, 5]) print(s) # fetching the absolute values print("\nThe absolute values are :") print(s.abs()) Output : Example 2 : Absolute numeric values in a Series with complex numbers. # import the library import pandas as pd # create the Series s = pd.Series([2.2 + 1j]) print(s) # fetching the absolute values print("\nThe absolute values are :") print(s.abs()) Output : Example 3 : Absolute numeric values in a Series with a Timedelta element. # import the library import pandas as pd # create the Series s = pd.Series([pd.Timedelta('2 days')]) print(s) # fetching the absolute values print("\nThe absolute values are :") print(s.abs()) Output : Example 4 : Fetching the absolute values from a DataFrame column. # import the library import pandas as pd # create the DataFrame df = pd.DataFrame({'p' : [2, 3, 4, 5], 'q' : [10, 20, 30, 40], 'r' : [200, 60, -40, -60]}) display(df) # fetching the absolute values print("\nThe absolute values are :") display(df.r.abs()) Output : Last Updated : 18 Aug, 2020 Like Article Save Article Previous Replace missing white spaces in a string with the least frequent character using Pandas Next Load JSON String into Pandas DataFrame Share your thoughts in the comments Add Your Comment Please Login to comment... Similar Reads Mapping external values to dataframe values in Pandas Highlight the negative values red and positive values black in Pandas Dataframe Absolute Deviation and Absolute Mean Deviation using NumPy | Python Pandas Series dt.day_name() Method | Get Day From Date in Pandas Pandas Series dt.weekofyear Method | Get Week of Year in Pandas Series Pandas Series dt.dayofyear | Get Day of Year in Pandas Pandas Series dt.days_in_month | Get Total Number of Days in Month in Pandas Pandas Series dt.dayofweek | Get Day of Week from DateTime Series in Pandas Pandas Series dt.daysinmonth | Get Number of Days in Month in Pandas Series Python | Pandas Series.nonzero() to get Index of all non zero values in a series Like zainabbas789 Follow Article Tags : Python Pandas-exercise Python pandas-series Python-pandas Python Practice Tags : python