get the absolute error between the columns "EV" from dataframe "df1" grouped by the column "TV" and "EV" from dataframe "df2" grouped by the column "TV" conserving the column "TV" transformed to string get the absolute error between the columns "MWh" from dataframe "df1" grouped by the column "TV" and "MWh" from dataframe "df2" grouped by the column "TV" conserving the column "TV" transformed to string
def get_error(df1, df2, column_name): # df1 and df2 must be dataframes and column_name is the name of the column in both dataframes return abs(df1[column_name] - df2[column_name]).groupby(df1["TV"].apply(str)).mean()