def _monthly_operation(self, operation, percentile=<NUM_LIT:0>):
<EOL>if operation == '<STR_LIT>':<EOL><INDENT>funct = self._average<EOL><DEDENT>elif operation == '<STR_LIT>':<EOL><INDENT>funct = self._total<EOL><DEDENT>else:<EOL><INDENT>assert <NUM_LIT:0> <= percentile <= <NUM_LIT:100>,'<STR_LIT>'.format(percentile)<EOL>funct = self._get_percentile_function(percentile)<EOL><DEDENT>data_dict = self.group_by_month()<EOL>new_data, d_times = [], []<EOL>for i in self.header.analysis_period.months_int:<EOL><INDENT>vals = data_dict[i]<EOL>if vals != []:<EOL><INDENT>new_data.append(funct(vals))<EOL>d_times.append(i)<EOL><DEDENT><DEDENT>new_header = self.header.duplicate()<EOL>if operation == '<STR_LIT>':<EOL><INDENT>new_header.metadata['<STR_LIT>'] = '<STR_LIT>'.format(percentile)<EOL><DEDENT>else:<EOL><INDENT>new_header.metadata['<STR_LIT>'] = operation<EOL><DEDENT>collection = MonthlyCollection(new_header, new_data, d_times)<EOL>collection._validated_a_period = True<EOL>return collection<EOL>
Get a MonthlyCollection given a certain operation.