@rasbt published this great post 4 a while ago where he explains cross validation in detail (you should also check other resources from his blog).
To perform the actual splitting you could use e.g. scikit-learn’s methods.