Last active
September 16, 2016 00:01
-
-
Save graham-thomson/49c2ff2bdedcad4481f0b62e2901f42a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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