How to convert netCDF4 time to datetime in python

  AI, Data Analytics, Python Basic


import netCDF4 as nc
import datetime
import netcdftime

fn = '/media/Data1/workdir/GANs/Data/reanalysis-era5-land_T2mPrAreaLat515545Lon_8885.nc'
ds = nc.Dataset(fn)

nctime=ds['time'][:]
t_cal=ds['time'].calendar
t_unit = ds.variables['time'].units
datevar = []
datevar.append(netcdftime.num2date(nctime,units = t_unit,calendar = t_cal))
datevar