def _limit_data(self, data):
if len(data.keys()) <= <NUM_LIT:10>:<EOL><INDENT>logger.debug("<STR_LIT>")<EOL>return data<EOL><DEDENT>avgs = {}<EOL>for k in data:<EOL><INDENT>if len(data[k]) <= <NUM_LIT:7>:<EOL><INDENT>vals = data[k]<EOL><DEDENT>else:<EOL><INDENT>vals = data[k][-<NUM_LIT:7>:]<EOL><DEDENT>avgs[k] = sum(vals) / len(vals)<EOL><DEDENT>final_data = {}  <EOL>other = []  <EOL>count = <NUM_LIT:0>  <EOL>for k in sorted(avgs, key=avgs.get, reverse=True):<EOL><INDENT>if count < <NUM_LIT:10>:<EOL><INDENT>final_data[k] = data[k]<EOL>logger.debug("<STR_LIT>"<EOL>"<STR_LIT>", k, avgs[k])<EOL><DEDENT>else:<EOL><INDENT>logger.debug("<STR_LIT>"<EOL>"<STR_LIT>", k, avgs[k])<EOL>other.append(data[k])<EOL><DEDENT>count += <NUM_LIT:1><EOL><DEDENT>final_data['<STR_LIT>'] = [sum(series) for series in zip(*other)]<EOL>return final_data<EOL>
Find the per-day average of each series in the data over the last 7
days; drop all but the top 10.

:param data: original graph data
:type data: dict
:return: dict containing only the top 10 series, based on average over
  the last 7 days.
:rtype: dict