cf.Data.last_element¶
-
Data.
last_element
()[source]¶ Return the last element of the data as a scalar.
New in version 1.7.0.
See also
Returns: The last element of the data. Examples:
>>> d = cfdm.Data(9.0) >>> x = d.last_element() >>> print(x, type(x)) (9.0, <type 'float'>)
>>> d = cfdm.Data([[1, 2], [3, 4]]) >>> x = d.last_element() >>> print(x, type(x)) (4, <type 'int'>) >>> d[-1, -1] = numpy.ma.masked >>> y = d.last_element() >>> print(y, type(y)) (masked, <class 'numpy.ma.core.MaskedConstant'>)
>>> d = cfdm.Data(['foo', 'bar']) >>> x = d.last_element() >>> print(x, type(x)) ('bar', <type 'str'>)