def as_old(v):
    if isinstance(v, ml_linalg.SparseVector):
        return mllib_linalg.SparseVector(v.size, v.indices, v.values)
if isinstance(v, ml_linalg.DenseVector):
    return mllib_linalg.DenseVector(v.values)
raise ValueError('Unsupported type {0}'.format(type(v)))
Create labeledPoints from Spark DataFrame in Python