Python pd using a variable with column name in groupby dot notation
Python pd using a variable with column name in groupby dot notation I am trying to use a list that holds the column names for my groupby notation. My end goal is to loop through multiple columns and run the calculation without having to re-write the same line multiple times. Is this possible? a_list = list(['','BTC_','ETH_']) a_variable = ('{}ClosePrice'.format(a_list[0])) proccessing_data['RSI'] = proccessing_data.groupby('Symbol').**a_variable**.transform(lambda x: talib.RSI(x, timeperiod=14)) this is the error I currently get because it thinks I want the column 'a_variable' which doesn't exist. AttributeError: 'DataFrameGroupBy' object has no attribute 'a_variable' use df[a_variable] instead of df.a_variable – RafaelC Jul 1 at 18:16 df...