Skip to content

Instantly share code, notes, and snippets.

@graham-thomson
Last active September 16, 2016 00:01
Show Gist options
  • Save graham-thomson/49c2ff2bdedcad4481f0b62e2901f42a to your computer and use it in GitHub Desktop.
Save graham-thomson/49c2ff2bdedcad4481f0b62e2901f42a to your computer and use it in GitHub Desktop.
from pyspark.ml.linalg import Vectors
def delete_index_from_dv(dense_vector, index):
"""
Takes PySpark dense vector, removes element at index.
:dense_vector: PySpark dense vector to operate on.
:index: Index of element to delete.
:return: Dense vector with element at index removed.
"""
temp_list = list(dense_vector)
temp_list.pop(index)
return Vectors.dense(temp_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment