1

I found that in some other people's data, the value "--" sometimes appear in an numpy array. How to set an array element to be "--" ?

something like this:

[-- -- -- -- -- -- -- -- 0.27969929575920105 0.27994874119758606
 0.27715885639190674 0.26716524362564087 0.2594984173774719
 0.2584466338157654 0.2565436065196991 0.2539260685443878
 0.2531115710735321 0.25570642948150635 0.2644173204898834
 0.26860886812210083]
3
  • 1
    You will have to show an example of how you get these. Commented Nov 17, 2018 at 10:54
  • 1
    Did you try getting one of those items by index. x = arr[0]; print(repr(x), type(x), help(x)) Commented Nov 17, 2018 at 11:00
  • 1
    Looks like a masked array Commented Nov 17, 2018 at 11:00

1 Answer 1

4

That's a NumPy "masked array." It carries with it an array of booleans, and where they are True the data is understood to be invalid--and hence printed as --.

If you want to see the masked data, it's accessible using the .data property of the masked array (which of course you can print).

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.