2

When using: iris.pandas.as_series() or iris.pandas.as_dataframe()

to convert a 1d cube to pandas series or dataframe, I am suddenly getting the following error:

'real_datetime' object has no attribute 'nanosecond'

Here is a minimal reproducible version:

# import packages
import iris
import iris.pandas

# load netcdf file
cubelist=iris.load('netcdffile.nc')
cube=cubelist[0]

# attempt to convert to pandas series:
dfs = iris.pandas.as_series(cube, copy=True)

This used to work fine, only now it has started throwing the error:

AttributeError: 'real_datetime' object has no attribute 'nanosecond'

I'm guessing could be a pandas or cftime issue. Does any iris experts have any advice on how to remove nanosecond from the time coord in an iris cube? Or change nanosecond to zero?

Any help appreciated, I've spent more time than I'd like to admit trying to fix this!

Malik Asad
  • 441
  • 4
  • 15
Disting
  • 43
  • 1
  • 6
  • 1
    It turns out this is an error with the latest `cftime` version (specifically I think at v1.0.2), which introduced nanosecond time accuracy. This can be fixed by downgrading to v1.01 using the following: `conda install -c conda-forge cftime=1.0.1` - more info here: [https://github.com/SciTools/iris/issues/3216] – Disting Nov 07 '18 at 14:59

0 Answers0