def cross_validation_group(test_data, train_data):
    om1, om2 = np.meshgrid(test_data, train_data[0])
dist = (om1 - om2) ** 2
indexes = np.argsort(dist, axis=0)
return train_data[:, (indexes[0])]
print(cross_validation_group(test_data, train_data))
Maintaining a ratio when splitting up data in python function