df = df.apply(lambda x: np.square(x) if x.name in [ 'a', 'e', 'g'] else x, axis=1)
By Stewart McLaughlin at Feb 06 2021