Recently I started learning python. I want to define a function for columns in data frame. I want square of every value in column. Please check this code. It results in error in fifth line.
def new_fun(df,col_name='Open'): out = [] col=df[col_name] for element in col: out[element].append(element**2) return out