How to Covert from prolepticGregorian to datetime

125 Views Asked by At

I'm having issues to convert a dataframe with a prolepticGregorian (Comming for netCDF4) to a datetime, using

i3h.index = pd.to_datetime(i3h.index, format='%Y-%m-%d %')

And the error is

<class 'cftime._cftime.DatetimeProlepticGregorian'> is not convertible to datetime

How is possible to do it? I need it to use the .resample("1H").mean()

The Dataframe looks like the following

i3h

2022-01-01 01:30:00      0.000000
2022-01-01 04:30:00      0.000000
2022-01-01 07:30:00     17.655130
2022-01-01 10:30:00    182.508820
2022-01-01 13:30:00    210.705002
   
2071-12-31 10:30:00     60.053749
2071-12-31 13:30:00     50.852924
2071-12-31 16:30:00      8.414156
2071-12-31 19:30:00      0.000000
2071-12-31 22:30:00      0.000000

Name: S, Length: 146096, dtype: float32
rsds_nc = Dataset(rsds_nc_filepath)
rsds_data = rsds_nc.variables['rsdsAdjust']
rsds_data.set_auto_mask(False)
times = rsds_nc.variables['time']
time_convert = netCDF4.num2date(times[:], times.units, times.calendar)

DatFrame1 = pd.DataFrame(columns = range(len(lats)),index = time_convert[yr_id_start:yr_id_end])

Best Regards

Sergio

0

There are 0 best solutions below