cf.Data.first_element

Data.first_element()[source]

Return the first element of the data as a scalar.

New in version 1.7.0.

Returns

The first element of the data.

Examples:

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