Skip to main content
Changed pandas `abs()` URL
Source Link

If you use the formula you provided ((df1[n]-df2[n] / df1[n]) * 100), you will get different results. You can use the Pandas abs method: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.abs.htmlhttps://docs.python.org/3/library/functions.html#abs

Some examples:

a = {'x': [2], 'y': [4], 'z': [5]} b = {'x': [7], 'y': [9], 'z': [0]} df1 = pd.DataFrame(a) df2 = pd.DataFrame(b) df_abs = abs(df1 - df2) # Absolute difference df_abs = (df1 - df2 / df1) * 100 # Different results 

If you use the formula you provided ((df1[n]-df2[n] / df1[n]) * 100), you will get different results. You can use the Pandas abs method: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.abs.html

Some examples:

a = {'x': [2], 'y': [4], 'z': [5]} b = {'x': [7], 'y': [9], 'z': [0]} df1 = pd.DataFrame(a) df2 = pd.DataFrame(b) df_abs = abs(df1 - df2) # Absolute difference df_abs = (df1 - df2 / df1) * 100 # Different results 

If you use the formula you provided ((df1[n]-df2[n] / df1[n]) * 100), you will get different results. You can use the Pandas abs method: https://docs.python.org/3/library/functions.html#abs

Some examples:

a = {'x': [2], 'y': [4], 'z': [5]} b = {'x': [7], 'y': [9], 'z': [0]} df1 = pd.DataFrame(a) df2 = pd.DataFrame(b) df_abs = abs(df1 - df2) # Absolute difference df_abs = (df1 - df2 / df1) * 100 # Different results 
Source Link

If you use the formula you provided ((df1[n]-df2[n] / df1[n]) * 100), you will get different results. You can use the Pandas abs method: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.abs.html

Some examples:

a = {'x': [2], 'y': [4], 'z': [5]} b = {'x': [7], 'y': [9], 'z': [0]} df1 = pd.DataFrame(a) df2 = pd.DataFrame(b) df_abs = abs(df1 - df2) # Absolute difference df_abs = (df1 - df2 / df1) * 100 # Different results