<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def filter_by_key(self, keys, ID=None):
 """ Keep only Measurements with given keys. """

        keys = to_list(keys)
        fil = lambda x: x in keys
        if ID is None:
            ID = self.ID
        return self.filter(fil, applyto='keys', ID=ID)