A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://docs.scipy.org/doc/numpy/reference/generated/numpy.ma.compressed.html below:

numpy.ma.compressed — NumPy v2.3 Manual

numpy.ma.compressed#
ma.compressed(x)[source]#

Return all the non-masked data as a 1-D array.

This function is equivalent to calling the “compressed” method of a ma.MaskedArray, see ma.MaskedArray.compressed for details.

Examples

Create an array with negative values masked:

>>> import numpy as np
>>> x = np.array([[1, -1, 0], [2, -1, 3], [7, 4, -1]])
>>> masked_x = np.ma.masked_array(x, mask=x < 0)
>>> masked_x
masked_array(
  data=[[1, --, 0],
        [2, --, 3],
        [7, 4, --]],
  mask=[[False,  True, False],
        [False,  True, False],
        [False, False,  True]],
  fill_value=999999)

Compress the masked array into a 1-D array of non-masked values:

>>> np.ma.compressed(masked_x)
array([1, 0, 2, 3, 7, 4])

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4