NCAS-CMS / cf-python

A CF-compliant Earth Science data analysis library
http://ncas-cms.github.io/cf-python
MIT License
126 stars 19 forks source link

New method: `cf.Field.filled` #811

Closed davidhassell closed 2 months ago

davidhassell commented 2 months ago

It would be useful to provide the filled method to Field objects - it is currently only defined on cf.Data (https://ncas-cms.github.io/cf-python/method/cf.Data.filled.html).

So, currently, to fill a field's missing values no in-place you have to do something like

>>> g = f.copy()
>>> g.data.filled(0, inplace=True)

but it would be much nicer to be able to do, with the same result:

>>> f.filled(0, inplace=True)