I've been suddenly getting this error when I try to plot a single grid cell (grabbed with a .sel
method)
float() argument must be a string or a number, not 'cftime._cftime.DatetimeGregorian'
my .time
coordinates are:
array([cftime.DatetimeGregorian(2000, 1, 1, 0, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2000, 2, 1, 0, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2000, 3, 1, 0, 0, 0, 0, has_year_zero=False),
...,
cftime.DatetimeGregorian(2049, 10, 1, 0, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2049, 11, 1, 0, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2049, 12, 1, 0, 0, 0, 0, has_year_zero=False)],
dtype=object
And I read in the full dataset using:
ds = xr.open_mfdataset(files, combine='nested', concat_dim='time', parallel=True,
preprocess=functools.partial(preprocess, varset=varset))
ds['time'] = xr.cftime_range(str(2000), periods=12*50, freq='MS') #fix time bug
Any help would be much appreciated!
nevermind I fixed this by importing nc_time_axis
!
Adrianna Foster has marked this topic as resolved.
Last updated: May 16 2025 at 17:14 UTC