Implementation of Dataset.apply method

Fixes #140