cf.Data.second_element

Data.second_element()[source]

Return the second element of the data as a scalar.

Performance

If possible, a cached value is returned. Otherwise the delayed operations needed to compute the element are executed, and cached for subsequent calls.

Returns

The second element of the data.

Examples

>>> d = cf.Data([[1, 2], [3, 4]])
>>> x = d.second_element()
>>> print(x, type(x))
2 <class 'int'>
>>> d[0, 1] = cf.masked
>>> y = d.second_element()
>>> print(y, type(y))
-- <class 'numpy.ma.core.MaskedConstant'>
>>> d = cf.Data(['foo', 'bar'])
>>> x = d.second_element()
>>> print(x, type(x))
bar <class 'str'>