0

I have a variable dense_vector it will print out DenseVector([0.0, 0.0, 0.9998]) when i print it

Is there a way to get only the array [0.0, 0.0, 0.9998]?

1
  • dense_vector.toArray() will give you an array. Commented Dec 10, 2018 at 17:25

1 Answer 1

1

In your case - at least according to the docs I found - you should be able to access those values with DenseVector.values.

General answer:

The string representation of an object must not neccassarily reflect the object's content. The data could be stored as a list, tuple, dict, attribute, ... within the class instance, so your best bet is to look at the __str__ / __repr__ implementation and build the list yourself.

Or, if it's your own class, create a method that returns the list, or you could even sub-class the class and then add a method on your own class that returns the list.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.