<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def apply(self, df):
 """Compute aggregate over DataFrame"""


        if self.subset:
            if _axis_is_rows(self.axis):
                df = df[self.subset]
            if _axis_is_cols(self.axis):
                df = df.loc[self.subset]

        result = df.agg(self.func, axis=self.axis, *self.args, **self.kwargs)
        result.name = self.title
        return result